1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| procedure Tform1.ProcExec(FileExec: string);
var
AProcess: Tprocess;
OutputLines: TStringList;
OutputError: TStringList;
begin
AProcess := TProcess.Create(nil);
AProcess.Executable := FileExec;
OutputLines := TStringList.Create;
OutputError := TStringList.Create;
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
//AProcess.ShowWindow := swoHIDE;
AProcess.Execute;
OutputLines.LoadFromStream(Aprocess.Output);
OutputError.LoadFromStream(AProcess.Stderr);
if OutputError.Text <> '' then
ShowMessage('ERREUR:'+#13#10+ConsoletoUtf8(OutputError.Text))
else
ShowMessage(ConsoletoUtf8(OutputLines.Text));
AProcess.Terminate(0);
AProcess.Free;
end; |
Partager