我有一个关于 Lazarus 的项目,我想使用 gcc 编译源代码,为此我有一个TOpenDialog
calledOpenDialog1
和一个TProcess
called AProcess
。
我用这段代码调用 gcc:
procedure TFormMain.btCompileClick(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
AProcess := TProcess.Create(nil);
try
AProcess.CommandLine := 'gcc.exe ' + OpenDialog1.FileName;
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
AProcess.Execute;
OutputMemo.Lines.BeginUpdate;
OutputMemo.Lines.Clear;
OutputMemo.Lines.LoadFromStream(AProcess.Output);
OutputMemo.Lines.EndUpdate;
finally
AProcess.Free;
end;
end;
end;
它编译正常(Lazzarus 上的项目),但是当我测试它时,通过尝试编译位于的源 test.c,C:\Documents and Settings\Nathan Campos\Desktop
我得到了这个OutputMemo
:
'C:\Documents': 没有这样的文件或目录
然后,OpenDialog1
没有得到带空格的完整路径,或者 gcc 无法在带空格的文件夹中找到它。
有什么建议可以帮助我吗?