[fpc-pascal] TProcess does not work in Windows XP
Michael Van Canneyt
michael at freepascal.org
Wed Mar 25 08:41:39 CET 2015
On Wed, 25 Mar 2015, Antonio Sanguigni wrote:
> 2015-03-25 5:01 GMT+01:00 leledumbo <leledumbo_cool at yahoo.co.id>:
>> 1. Define "does not produce any results."
> Simply I cannot get output from console app which I'm trying to run
> and capture. Again, this is happening just for windows xp. Same
> procedure (follow code) in Windows 7 is right.
>> 2. Show your code
> Yes, you are absolutely right. Here it is. I did not use RunCommand
> because it does not seem to work for me. Problem was such as above, I
> mean no output from console app to run.
> ---------------------- code ---------------
> procedure TBurpClient.Run;
> fOurProcess.Options := [poUsePipes] + [poNoConsole];
> while True do
> // make sure we have room
> fMemStream.SetSize(fBytesRead + READ_BYTES);
> // try reading it
> fNumBytes := fOurProcess.Output.Read((fMemStream.Memory +
> fBytesRead)^, READ_BYTES);
> if fNumBytes > 0 then // All read() calls will block, except the final one.
I am not sure this is always correct. Various versions of windows work differently in this regard;
zero (0) may be a valid return value. I suggest you check fOurProcess.IsRunning to break the loop.
More information about the fpc-pascal