Inno setup 在[RUN]部分使用变量

Inno setup 在[RUN]部分使用变量,inno-setup,Inno Setup,我想在[RUN]部分读一个var值,kets说这是我的代码- [Setup] [Files] Source: "MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion [Run] Filename: "{app}\MyProg.exe"; Description: ""; parameters:"/setid=SessionIDValue" [code] var SessionIDValue: String; procedure

我想在[RUN]部分读一个var值,kets说这是我的代码-

[Setup]

[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion

[Run]
Filename: "{app}\MyProg.exe"; Description: ""; parameters:"/setid=SessionIDValue"

[code]
var

    SessionIDValue: String;

procedure InitializeWizard();

  begin

    SessionIDValue:= 'test';

    end;
是否可以将
SessionIDValue
值传递给
参数:“/setid=SessionIDValue”

10X要获得帮助

您可以编写一个脚本化常量getter函数,以将该部分与脚本部分连接起来,例如:

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

[Code]
var
  SessionID: string;

function GetSessionID(Param: string): string;
begin
  Result := SessionID;
end;

再说一次,Tlama我知道这个解决方案,难道没有更简单的方法来传递var值吗?inno安装程序无法在其分区中传递var?不,没有。Inno安装程序没有在
[code]
节中声明的全局变量的可扩展常量(例如
{reg:}
{param:}
等)。这是目前唯一的方法。值得一提的是,您可以为许多变量编写一个getter,并根据输入参数返回变量值,例如通过类似索引的方式。