如何使用免费 Pascal/Lazarus 运行 外部应用程序?

How do I run an external application with Free Pascal/Lazarus?

我如何 运行 使用免费 Pascal/Lazarus 的外部应用程序(使用 Windows)?我找到了 "official" reference page,其中有几个实现和示例。虽然我确信它适用于很多人,但以我目前的知识水平,我有些迷茫(我还没有太多使用 Free Pascal 进行常规编程,而且我在网上找到的其他示例对我)。

是否有 "clear" 示例可以帮助我完成 "first steps"?谢谢

这是一个工作示例(source) using TProcess

uses Process;
var
  RunProgram: TProcess;
begin
  RunProgram := TProcess.Create(nil);
  RunProgram.CommandLine := ‘Path and Name of Program’;
  RunProgram.Execute;
  RunProgram.Free;
end;

例如,这将打开应用程序 "MS Notepad":

uses Process;
var
  RunProgram: TProcess;
begin
  RunProgram := TProcess.Create(nil);
  RunProgram.CommandLine := ‘notepad.exe’;
  RunProgram.Execute;
  RunProgram.Free;
end;

如果你不需要管道,你可以只使用执行过程。

uses sysutils;
begin
  executeprocess('notepad.exe',['document.txt']);
end.