Try something along this line:
LPSTR cmdLine;
// set your commandline here
PROCESS\_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo = {0};
StartupInfo.cb = sizeof(STARTUPINFO);
if (::CreateProcess(NULL, cmdLine, NULL, NULL, FALSE,
0, NULL, NULL, &StartupInfo, &ProcessInfo))
{
DWORD dwStatus = STILL\_ACTIVE;
while (dwStatus == STILL\_ACTIVE)
{
::GetExitCodeProcess(ProcessInfo.hProcess, &dwStatus);
Sleep(1000);
}
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
}
You may need/want to use peekMessage and TranslateMessage inside the while loop in order to intercept messages.