Solved

CreateProcess and hiding the window

Posted on 1997-07-23
3
1,280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

690 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