Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ExecAndWait(Path: string; Wait: boolean; Window: word): integer;
- var
- si: TStartupInfo;
- p: TProcessInformation;
- RetCode: DWord absolute result;
- begin
- FillChar(Si,SizeOf(Si),0);
- with Si do begin
- cb := SizeOf( Si);
- dwFlags := startf_UseShowWindow;
- wShowWindow := Window;
- end;
- Createprocess(nil,pChar(Path),nil,nil,false, Create_default_error_mode,nil,nil,si,p);
- result:= p.hProcess;
- if Wait then begin
- Waitforsingleobject(p.hProcess,infinite);
- if not GetExitCodeProcess(p.hProcess, RetCode) then result:= -1;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment