GetExitCodeProcess ExitProcess Tester..
Done CreateProcess OK,
Now want to ExitProcess aqain.......
problem lies in how I give the ExitProcess the exitstatus code
from within my program......
How do I use GetExitCodeProcess....or what do I do
See my code below
Thanks......
Tony.void __fastcall TfmCreateProcess::OpenNotepadClick(TObject *Sender)
{
// don't enter the function if we are already waiting
// for another instance of notepad to close.
if(bWaiting)
return;
char szWindowDir [MAX_PATH];
GetWindowsDirectory(szWindowDir, MAX_PATH);
AnsiString strNotepad = AnsiString(szWindowDir) + "\\notepad.exe";
strNotepad = strNotepad + " " + "c:\\_CutSizes\\Readme.txt";
STARTUPINFO StartupInfo;
ZeroMemory( &StartupInfo, sizeof(STARTUPINFO));
StartupInfo.cb = sizeof(STARTUPINFO);
PROCESS_INFORMATION ProcessInfo;
if(CreateProcess(NULL, strNotepad.c_str(), NULL, NULL,
TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL,
&StartupInfo, &ProcessInfo))
{
bWaiting = true;
Label1->Caption = "Waiting for Notepad to close";
dwExitStatus = STILL_ACTIVE;
// loop until Notepad closes.........
// NOTE: this is where I want another button on
// my form to close Notepad....question is how do
// I get the exitstatus code in order to execute
// ExitProcess....?
do
{
if( !GetExitCodeProcess(ProcessInfo.hProcess, &dwExitStatus))
break;
Application->ProcessMessages();
} while (dwExitStatus == STILL_ACTIVE);
Label1->Caption = "done";
bWaiting = false;
// dont' need the handles any more, so close them
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
}
}