在 运行 或 Inno Setup 的其他部分中使用全局字符串脚本变量

Using global string script variable in Run or other section in Inno Setup

我需要 Inno Setup 中的全局字符串变量,它将在 [Code] 部分中初始化并在 [Run] 部分中使用。

这可能吗?

您可能正在寻找 scripted constant:

[Run]
Filename: "{app}\MyProg.exe"; Parameters: "{code:GetGlobalVariable}"

[Code]

var
  GlobalVariable: string;

function GetGlobalVariable(Param: string): String;
begin
  Result := GlobalVariable;
end;

function InitializeSetup(): Boolean;
begin
  GlobalVariable := '/parameter';

  Result := True;
end;

有关更真实的示例,请参阅