Re: CreateProcess leaves child windows on rear
The problem is not in this code. What do you do after this code?
By the way I would use GetWindowsDirectory() instead of hard coding
C:\Windows
AliR.
<hq4000@hotmail.com> wrote in message
news:1174401801.472849.27650@o5g2000hsb.googlegroups.com...
After build the following code as test.exe. The test.exe starts the
notepad.exe ok, but it has the notepad.exe window stays behind an
active window if there is any. How can I ensure the notepad.exe is
created stays on the front of other active window?
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
ZeroMemory( &ProcessInformation, sizeof( ProcessInformation ) );
ZeroMemory( &StartupInfo, sizeof( StartupInfo ) );
StartupInfo.cb = sizeof( STARTUPINFO );
StartupInfo.dwFlags = CREATE_NEW_CONSOLE;
FolderPath[0] = _T('\0');
CommandString[0] = _T('\0');
StringCchCatW(FolderPath, MAX_PATH,_T("C:\\Windows"));
StringCchCatW(CommandString, MAX_PATH, _T("C:\\Windows\
\Notepad.exe"));
CreateProcess(NULL,
CommandString,
NULL,
NULL,
TRUE,
0,
NULL,
FolderPath,
&StartupInfo,
&ProcessInformation );
...
}