1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37:
| function WaitForAppDone(process: string): boolean; var proc_info: TProcessInformation; startinfo: TStartupInfo; ExitCode: longword; begin FillChar(proc_info, sizeof(TProcessInformation), 0); FillChar(startinfo, sizeof(TStartupInfo), 0); startinfo.cb := sizeof(TStartupInfo);
if CreateProcess( PChar(process), nil, nil, nil, false, IDLE_PRIORITY_CLASS, nil, PChar(ExtractFilePath(process)), startinfo, proc_info ) <> False then begin WaitForSingleObject(proc_info.hProcess, INFINITE); GetExitCodeProcess(proc_info.hProcess, ExitCode); CloseHandle(proc_info.hThread); CloseHandle(proc_info.hProcess); result:= true; end else begin result:= false; end;end; |