If I'm understanding correctly (I'm not certain I am, your description is anything but clear) something like this might help (you can wait on a process handle):
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
BOOL bOk = CreateProcess(
_T("C:\\Windows\\system32\\notepad.exe"),
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi
);
if (bOk)
{
CloseHandle(pi.hThread); // We don't need so don't leak it!
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess); // We're finished with it.
MessageBox(NULL, \_T("Finished"), \_T("Create and wait"), MB\_OK);
}
Steve