Solved

CreateProcess and hiding the window

Posted on 1997-07-23
3
1,077 Views
Last Modified: 2008-03-06
I am trying to use the createprocess to launch a Dos Shell and I would like that Dos window to be hidden.  Just like using Shell with vbhide.  The whole process I am doing is to use createprocess and then wait for the launched shell to end.  But I want that window hidden.

Any ideas???
0
Comment
Question by:mnaber
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
vorlon earned 100 total points
ID: 1428761
mnaber,
I've never used CreateProcess myself but here is some information I got from my documentation:

CreateProcess needs 10 parameters. The second from the end of type LPSTARTUPINFO is a pointer to a structure (user-defined type in visual basic) is what you need to setup.

The STARTUPINFO user-defined type has a field called wShowWindow and this value must be set to any one of the constants you would pass to ShowWindow. In your case, set it to SW_HIDE. Also, make sure your flags have a value including STARTF_USESHOWWINDOW otherwise the SW_HIDE has no effect. Like this:

'declare constants needed
Public Const STARTF_USESHOWWINDOW = &H1
Public Const SW_HIDE = 0

'declare the startupinfo structure
Type STARTUPINFO
   cb As long
   lpReserved as string
   lpDesktop as string
   lpTitle as string
   dwx as long
   dwy as long
   dwXSize as long
   dwYSize as long
   dwXCountChars as long
   dwYCountChars as long
   dwFillAttribute as long
   dwFlags as long
   wShowWindow as integer
   cbReserved2 as integer
   lpReserved2 as long
   hStdInput as long
   hStdOutput as long
   hstdError as long
End Type

   ...
   'declare variable for startupinfo
   Dim si As STARTUPINFO
   ...

   'initialize si structure
   si.cb = Len(si)'must set length of variable
   si.Flags = STARTF_USESHOWWINDOW'needed othersiwe SW_HIDE will not work
   si.wShowWindow = SW_HIDE'hide the window on startup
   ...

If you need a full (100%) sample, let me know... This snippet was removed from chapter 14 of "Visual Basic Programmer's Gude to the Win32 API" by Daniel Appleman. I find it to be an excellent resource.

Hope this helps.
0
 

Author Comment

by:mnaber
ID: 1428762
The only thing that was wrong is line that says FLAGS should be dwFlags.

Mark
0
 
LVL 2

Expert Comment

by:vorlon
ID: 1428763
mnaber,
Sorry. Other controls have a "flags" property. I assumed this was just the same without even looking at my references...

Glad it worked for you.
vorlon
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now