Re: CreateProcess leaves child windows on rear

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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@xxxxxxxxxxx> wrote in message
news:1174401801.472849.27650@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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 );
...
}



.



Relevant Pages

  • CreateProcess leaves child windows on rear
    ... active window if there is any. ... ZeroMemory(&ProcessInformation, sizeof(ProcessInformation)); ... ZeroMemory(&StartupInfo, sizeof(StartupInfo)); ...
    (microsoft.public.vc.mfc)
  • Re: STARTUPINFO is not working ?
    ... it will just decrement the reference count on the kernel process object. ... STARTUPINFO functionality is not working. ... ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); ... CloseHandle(pi.hProcess); ...
    (microsoft.public.win32.programmer.kernel)
  • Re: STARTUPINFO is not working ?
    ... you should not assume that STARTUPINFO is the problem. ... whether your program is a console or GUI program. ... ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); ... CloseHandle(pi.hProcess); ...
    (microsoft.public.win32.programmer.kernel)
  • Re: STARTUPINFO is not working ?
    ... you should not assume that STARTUPINFO is the problem. ... ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); ... CloseHandle(pi.hProcess); ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Run an application from remote PC
    ... FillChar(startUpInfo, 0, SizeOf(startUpInfo)); ... if not CreateProcess(Nil, pChar(cmd), ...
    (borland.public.delphi.non-technical)