我正在使用Lazarus开发一个程序,执行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, poUsePipes];
AProcess.Execute;
AProcess.Free;
end;
但是我想在另一个只有TMemo(OutputForm
)的Form(OutputMemo
)上显示gcc的日志(输出)。
我该怎么做?
答案 0 :(得分:2)
试试这段代码
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;