Hi Colin,
The following should do what you want.
procedure ExecProgram(const ProgName : String; const Wait : Boolean; const Visibility : integer); var StartupInfo : TStartupInfo; ProcessInfo : TProcessInformation; Rslt : LONGWORD; r : boolean; begin FillChar(StartupInfo, sizeof(StartupInfo), 0); With StartupInfo Do Begin cb:= sizeof(StartupInfo); dwFlags:= STARTF_USESHOWWINDOW; wShowWindow:= Visibility; End; r:= CreateProcess(Nil, PChar(ProgName), Nil, Nil, False, NORMAL_PRIORITY_CLASS, Nil, Nil, StartupInfo, ProcessInfo); If not r then Begin MessageDlg('Create Process Error', mtError, [mbOk], 0); Exit; End; Application.ProcessMessages; If Wait then Begin Repeat WaitforSingleObject(ProcessInfo.hProcess, 100); Application.ProcessMessages; GetExitCodeProcess(ProcessInfo.hProcess, Rslt); Until not (Rslt = STILL_ACTIVE); End; CloseHandle(ProcessInfo.hProcess); CloseHandle(ProcessInfo.hThread); end; Regards
Steve Galyer
|
- [DUG]: Execute and Wait Colin R Dillicar
- [DUG]: Execute and wait Steve Galyer
- [DUG]: Execute and wait vss
- Re: [DUG]: Execute and wait Corey Murtagh
- RE: [DUG]: Execute and wait Chris Milham
- RE: RE: [DUG]: Execute and wait Chris Milham
- RE: RE: RE: [DUG]: Execute and wait Chris Milham
- RE: RE: RE: [DUG]: Execute and wait Chris Milham