执行一个程序并等待它结束
function ExecuteAndWaitProcess(
const ACmdLine : string;
const ACurrDir : string = ''
):Boolean;
var
SI: TStartupInfo;
PI: TProcessInformation;
begin
FillChar(SI, SizeOf(SI), 0);
SI.cb := SizeOf(SI);
SI.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
SI.wShowWindow := SW_HIDE;
Screen.Cursor := crHourGlass;
try
CreateProcess(
nil,
PChar(ACmdLine),
nil,
nil,
True,
0,
nil,
PChar(ACurrDir),
SI,
PI);
WaitForSingleObject(PI.hProcess, INFINITE);
Result := True;
finally
Screen.Cursor := crDefault;
end;
end;