How to hide command prompt screen using _spawnl/shellexecute

Started by
8 comments, last by cutesiham 21 years, 5 months ago
Hi all i wish to call up my child process from my main process. let say my child process is a console program, if i call .exe using shellexecute / _spawnl / _execl, but the command prompt window is shown on the screen. make the thing simple, if i my console program call a MessageBox, if my main process call the .exe, the messagebox is what i expected instead of showing the black command prompt window. is there anyway to get rid of the console screen? i try to call up other non_console .exes,and they works fine. but just wondering how to cater the console program thank you from damian
Advertisement
all console programs get a default console window; there''s nothing you can do about it.
well, thanks for yours info.

and i got another problem as well. let say i call a non_console
program, is that any way to hide the window.

for instance, if i call the program which is able to do some
calculation for me, so my target is the result but not the window
screen. I use the spawnl to pass in the arguments for the
calculation. eHmmmm....i just want to hide the front-end view,
so is there any win32api or shell commands to solve this?

thank you
In your other program while you are initializing the window, like this :


      if(!(hWnd = CreateWindowEx(NULL, //Extra window styles                           "Game Engine 1", //Class name                            "Gane Engine", //Window title                           WS_POPUP | WS_VISIBLE, //Window styles                           0, 0, 640, 480, //Top left        corner,width and height                           NULL, //Parent window                           NULL, //Menu thing                           hInstance, //This instance                           NULL))) //Never used                           {                           	return 0;	                   }      


don't set it's style, so instead of WS_POPUP | WS_VISIBLE, put NULL there instead I believe. If that doesn't work, lookup CreateWindowEx or CreateWindow in MSDN and look at the windows styles and look for one that doesn't show the window. I think that WS_HIDDEN might be what you are looking for, but I do not recall. It has been a while since I have done Win32 for my game engine.

Hope that helps,
Michael Bartman
Dark Omen Studios
Lead Engine Programmer

*edit* I couldn't find WS_HIDDEN in msdn, so that won't work. Try the NULL thing I was talking about

[edited by - TheBartman on November 7, 2002 2:26:05 AM]
Michael BartmanDark Omen StudiosLead Engine Programmer
Well, i m trying to call the exe file written by other auhor.
perhaps i should name it off-to-shelf product.

i m taking the role now to call the exe using my own program.
so it is impossible for me to change the window type which u
recommend me to do so.

anyway. thank you so much, though i gain another lesson :-)


from damian
some trickery with EnumWindows, GetWindowThreadProcessId, and toolhelp32, and then ShowWindow will probably work. don''t you wish there was a EnumProcessWindows function?
Check out the CreateProcess() Windows API function and pay attention to the wShowWindow parameter of the STARTUPINFO structure that is passed to CreateProcess. You should set it to SW_HIDE. You need to set other values as well. Check out the link for more info.

[edited by - chronos on November 7, 2002 2:57:47 AM]
i clearly missed the obvious.
well. thank you so much.
i use the ShellExecute command to execute the exe and at the same time trigger the function to execute the parameters which i pass in to the command.

i pass in the last parameter value - SW_HIDE to the shellexecute function.

thank you , anyway

from damian
You can also pass the CREATE_NO_WINDOW parameter to CreateProcess to hide the console window. This flag is only valid on Windows NT/2000/XP though. (In my opinion, anyone using 95/98/ME is crazy anyway )

If I had my way, I''d have all of you shot!

codeka.com - Just click it.

This topic is closed to new replies.

Advertisement