==============
STARTUPINFO siStartInfo; /* Input values */
memset( &siStartInfo, 0, sizeof(STARTUPINFO) );
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.dwFlags=STARTF_USESHOWWINDOW ;
siStartInfo.ShowWindow = SW_NORMAL ;
if ( FALSE == CreateProcess(
NULL, /* Executable is first token in cmd */
child_path, /* command line */
NULL, /* process security attributes */
NULL, /* primary thread security attributes */
FALSE, /* handles are inherited */
CREATE_NEW_CONSOLE |
CREATE_NEW_PROCESS_GROUP, /* create flags, see
GenerateConsoleCtrlEvent() */
NULL, /* use parent's environment */
NULL, /* use parent's current directory */
&siStartInfo, /* Startup Input argument */
&piProcInfo )) /* Startup Output argument */
{
// do something ...
}
==============
The code is working fine, to some extent. i.e., i call this
CreateProcess lot of times, but for the first 4 times, the spawned
window is coming on top of the window stack, but wierdly, the spawned
window is going to bottom of window stack from 5th time. I've been
banging my head on this problem for the whole of last week, but could
not find any solution. Is this a setting in windows or it has got
something to do with my program. Any clues will be greatly
appreciated.
Thanks in advance,
Surya