[fpc-pascal] Question about TProcess

Darius Blaszijk dhkblaszyk at zeelandnet.nl
Fri May 11 01:18:52 CEST 2007


Thanks Vincent,

I did not think of it as there are only about 30lines of output. It 
works now.

Darius


Vincent Snijders wrote:
> 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
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>



More information about the fpc-pascal mailing list