Solved

CreateProcess and hiding the window

Posted on 1997-07-23
3
1,102 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Window placement 17 74
Replace Formatted Numbers with text 9 61
MS Access - Capture pressed key onclick 4 28
Put text in a picture ASP.NET C# 2 50
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

929 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

13 Experts available now in Live!

Get 1:1 Help Now