Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide DOS window when exec-ing a command

Status
Not open for further replies.

PROPAR

Programmer
Oct 25, 2001
51
FR
Hello,
When I launch an exec file with a VC6 spawn call, I get a DOS window.

For example :
_spawnlp(_P_WAIT, ".\my_exec.exe", "my_arg0", "m_arg1", NULL)
pops briefly an ugly DOS window while executing.

How can iconify or hide the popping DOS window (I want a silent synchronous execution of "my_exec.exe) ?

Thank you for youy help.
 
The dos window is created because "main" is used as entry point of the called program. That makes it a console program.

Use entry point
Code:
int WinMain ( HINSTANCE hInstance,
              HINSTANCE hPrevInstance,
              LPSTR lpCmdLine,
              int nCmdShow )
instead of
Code:
int main ( int argn, char **argv )

You need to separate the parameters (lpCmdLine) by yourself.




Marcel
 
Another answer is just to call 'ShellExecute' with the SW_HIDE parameter. This worked beautifully for me, especially when you don't have access to the code for the .exe file you're trying to call...

ShellExecute(0, "open", "whatever.exe", args, 0, SW_HIDE);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top