开发者

Output Of a Process

I'm developing a program using Lazarus, that execute gcc:

var
AProcess: TProcess;

begin
if SaveDialog1.Execute then
AProcess := TProcess.Create(nil);
AProcess.CommandLine := 'gcc.exe ' + SaveDialog1.FileName + ' -o ' TextField23.Text;
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipe开发者_JAVA技巧s];
AProcess.Execute;
AProcess.Free;
end;

But I want to display the log(output) of gcc on another Form(OutputForm), that have only a TMemo(OutputMemo).

How can I do it?


you can use the Output property from the TProcess object.

try this code

var
  AProcess: TProcess;
begin
  if SaveDialog1.Execute then begin
    AProcess := TProcess.Create(nil);
    try
      AProcess.CommandLine := 'gcc.exe ' + SaveDialog1.FileName + ' -o '
        + TextField23.Text;
      AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
      AProcess.Execute;

      OutputForm.OutputMemo.Lines.BeginUpdate;
      //OutputForm.OutputMemo.Lines.Clear;
      OutputForm.OutputMemo.Lines.LoadFromStream(AProcess.Output);
      OutputForm.OutputMemo.Lines.EndUpdate;
    finally
      AProcess.Free;
    end;
  end;
end;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜