How to use a Pascal variable in Inno Setup?

前端 未结 1 1773
野趣味
野趣味 2021-01-20 00:02
[Files]
Source: \"C:\\MyProg.exe\"; DestDir: \"{app}\"; BeforeInstall: GetHome(); Flags: ignoreversion
[INI]
Filename: \"{myVarFromPascal}\\.MyProg\\settings.ini\";          


        
相关标签:
1条回答
  • 2021-01-20 00:28

    You will need to change your variable to be in the global scope and write a simple getter function for so called scripted constant:

    [Files]
    Source: "C:\MyProg.exe"; DestDir: "{app}"; BeforeInstall: GetHome; Flags: ignoreversion
    
    [INI]
    Filename: "{code:GetMyVar}\.MyProg\settings.ini"; Section: "Settings"; Key: "sound"; String: "1"; Flags: createkeyifdoesntexist
    
    [Code]
    var
      myPascalVar: string;
    
    function GetMyVar(Value: string): string;
    begin
      Result := myPascalVar;
    end;
    
    procedure GetHome;
    begin
      RegQueryStringValue(HKEY_CURRENT_USER, 'Volatile Environment', 'USERPROFILE', myPascalVar);
      MsgBox('Value is "' + myPascalVar + '"', mbInformation, MB_OK);
    end;
    
    0 讨论(0)
提交回复
热议问题