[fpc-pascal] Question about TProcess
Darius Blaszijk
dhkblaszyk at zeelandnet.nl
Fri May 11 00:30:44 CEST 2007
The following piece of code is giving me headaches. When I add the
option poUsePipes, the application starts and does not seem to do
anything else anymore. It just opens a commandline terminal and that is
that. When I leave the option out the application actually starts "make"
and then crashes because AProcess.Output is nil.
What did I forget? I'm working on WinXP. On Linux btw the code works.
Darius
procedure ExecuteApp(CmdLine: string);
var
AProcess: TProcess;
AStringList: TStringList;
begin
AProcess := TProcess.Create(nil);
AStringList := TStringList.Create;
AProcess.CommandLine := CmdLine;
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
AProcess.Execute;
AStringList.LoadFromStream(AProcess.Output);
AStringList.SaveToFile('output.txt');
AStringList.Free;
AProcess.Free;
end;
begin
ExecuteApp('make');
end.
More information about the fpc-pascal
mailing list