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