执行并等待进程完成

function ExecAppWait(AppName, Params: string): Boolean; var ShellExInfo: TShellExecuteInfo; begin FillChar(ShellExInfo, SizeOf(ShellExInfo), 0); with ShellExInfo do begin cbSize := SizeOf(ShellExInfo); fMask := see_Mask_NoCloseProcess; Wnd := Application.Handle; lpFile := PChar(AppName); lpParameters := PChar(Params); nShow := sw_ShowNormal; end; Result := ShellExecuteEx(@ShellExInfo); if Result then while WaitForSingleObject(ShellExInfo.HProcess, 100) = WAIT_TIMEOUT do begin Application.ProcessMessages; if Application.Terminated then Break; end; end;

你可能感兴趣的:(执行并等待进程完成)