// Create the process
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
BOOL bCreate;
bCreate = CreateProcess(szProcessName, szCmdLine, NULL, NULL, TRUE,
CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS,NULL, szProcessPath, &si, &pi);
// Wait for the end of the process
while(WaitForSingleObject(pi.hProcess, 250) == WAIT_TIMEOUT)
{
//Do something here
}
// Terminate the process
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);