Solved

CreateProcess and hiding the window

Posted on 1997-07-23
3
1,196 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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
String manipulation in Visual Basic 7 73
Dinamic report to Crosstab query 9 33
transition to visual .net from vb6 5 37
Collapse and expand table in Word 2010 2 32
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

856 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