I need to create a child process as a socket listener/server for my main process and I use this call to achieve the goal:
bSuccess = CreateProcessA(NULL,
cmdLineArgs, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
HIGH_PRIORITY_CLASS, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo); // receives PROCESS_INFORMATION
Could anyone state what needs to be done in order for the child process' window not to show up? It's undesirable to have a visible process window each time the main, central process creates a child.
LATER EDIT I used:
HWND hWnd = GetConsoleWindow();
if (hWnd != 0)
{
ShowWindow( hWnd, SW_HIDE);
}
in the child process main function, but this isn't really the best solution as the window still shows up for a fraction of a second. If one has several child processes, each with its own window bubbling onto the screen, it is still not elegant. Are there any flags to set for the compiler to produce a "console-less" output?
I'm using Visual Studio 2010.
The CREATE_NO_WINDOW flag is used for just this purpose.
You can add it to the dwCreationFlags bitmask like so:
bSuccess = CreateProcessA(NULL,
cmdLineArgs, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
HIGH_PRIORITY_CLASS | CREATE_NO_WINDOW, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo); // receives PROCESS_INFORMATION
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With