-
Loading a Process
Im working on a prog that basically just runs another program and waits for it to end, so far this is what i got:
Code:
void LoadProgram(char *sProgramPath)
{
STARTUPINFO startupInfo = {0};
PROCESS_INFORMATION processInfo;
CreateProcess(NULL, sProgramPath, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processinfo);
while (process running = true)
Sleep(100);
CloseHandle(processinfo.hThread);
CloseHandle(processinfo.hProcess);
}
Thats about all i could figure out, i was wondering, how could i check to see once the process has ended? so for example, i load notepad using the above function, then the function only returns once the user has exited notepad...
Thanks in advance
-
Here is how you would wait for the process to end:
Code:
WaitForSingleObject(processinfo.hProcess,INFINITE);
Call that function right after you create the process, and get rid of that while loop you have.
-
You must provide the size of the STARTUPINFO struct before use.
Code:
startupInfo.cb = sizeof(startupInfo);
-
thanks for the quick replies guyz