?
Solved

CreateProcess and hiding the window

Posted on 1997-07-23
3
Medium Priority
?
1,360 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 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

801 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