[fpc-pascal] TProcess does not work in Windows XP

Antonio Sanguigni a.sanguigni at gmail.com
Wed Mar 25 10:53:43 CET 2015


> Once more:
> Zero is a valid return value for read from a pipe.
>
> So it can perfectly be that read attempts 50 times returns 0, and only at
> read attempt 51 you get a positive result.
>
> That is why you must check isRunning, and not rely on the return value of
> readbytes.

Thank you, this is my new code and while it's working good on Windows
7 it doesn't on Windows XP :(.

procedure TBurpClient.Run;
begin
  fOurProcess.Options := [poUsePipes] + [poNoConsole];
  fOurProcess.Execute;
  while fOurProcess.Running do
  begin
    // make sure we have room
    fMemStream.SetSize(fBytesRead + READ_BYTES);
    // try reading it
    fNumBytes := fOurProcess.Output.Read((fMemStream.Memory +
fBytesRead)^, READ_BYTES);
    Inc(fBytesRead, fNumBytes);
  end;

  fMemStream.SetSize(fBytesRead);
  fOutputLines := TStringList.Create;
  fOutputLines.LoadFromStream(fMemStream);
  fOutputLines.SaveToFile('output.txt');
  CommandOutput := fOutputLines.Text;
  faStringList.Assign(fOutputLines);
  fObjectList.Add(fOutputLines);
  Inc(fIndexOfOL);
  Inc(fIndexOfOL);
//  fOutputLines.Free;
end;


-- 
Antonio Sanguigni alias slapshot
----------------------------------------------------------------------
Servizi informatici Windows e GNU/Linux- http://www.pieroni.biz
GioveLUG (Linux User Group) - http://www.giovelug.org



More information about the fpc-pascal mailing list