I use CreateProcess () with start flags set to STARTF_USESHOWWINDOW and SW_HIDE to start the application in the background, hiding its window. I do this to perform scheduled maintenance tasks, and I do not want windows to bother you.
In most cases, the windows are hidden, but there are cases when the program window appears right in front of you (for example, Google Chrome - I started testing in different applications to find out if this was a problem once, but not ..).
On Windows XP, this happens less, but it happens very often on Vista.
Is there a flag that I am missing? Is there any other way to create a process with its hidden window?
Thanks!
my code example:
char *ProgramName
STARTUPINFO StartupInfoF;
PROCESS_INFORMATION ProcessInfoF;
memset(&StartupInfoF, 0, sizeof(StartupInfoF));
memset(&ProcessInfoF, 0, sizeof(ProcessInfoF));
StartupInfoF.cb = sizeof(StartupInfoF);
StartupInfoF.wShowWindow = SW_HIDE;
StartupInfoF.dwFlags = STARTF_USESHOWWINDOW;
if (CreateProcess(ProgramName,
"",
0,
0,
FALSE,
DETACHED_PROCESS,
0,
0,
&StartupInfoF,
&ProcessInfoF) == FALSE)
{
}
else
{
}