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

Antonio Sanguigni a.sanguigni at gmail.com
Wed Mar 25 08:36:10 CET 2015


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;
begin
  fOurProcess.Options := [poUsePipes] + [poNoConsole];
  fOurProcess.Execute;
  while True do
  begin
    // 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.
    begin
      Inc(fBytesRead, fNumBytes);
     // Write('.') //Output progress to screen.
    end
    else
      BREAK // Program has finished execution.
  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);
//  fOutputLines.Free;
end;
-------------------------------------------------

Thank you.

-- 
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