[fpc-pascal] Question about TProcess
Vincent Snijders
vsnijders at quicknet.nl
Fri May 11 00:34:13 CEST 2007
Darius Blaszijk schreef:
> 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.
Maybe the output buffer is full and the application is waiting for you
to read from the pipe. See the reading large output program at
http://wiki.lazarus.freepascal.org/Executing_External_Programs#Reading_large_output
Vincent
More information about the fpc-pascal
mailing list