How to declare an Inno Setup preprocessor variable by reading from a file

前端 未结 4 888
南旧
南旧 2020-12-09 18:46

Ok I know you can do this in Inno Setup:

#define AppVer \"0.0.11\"

Then use it like

[Setup]
AppVerName={#AppVer}

4条回答
  •  -上瘾入骨i
    2020-12-09 19:20

    In the event you want to do this at the installer's run time (@jachguate's answer covers the other possibility, and is probably the one you're looking for - I'll leave this in case it helps others at some point), you can use it's Pascal Script to do so. Something like this should work:

    [Setup]
    AppVer={code:MyVersion}
    
    [Files]
    // Other files
    Source: "YourVersionFile.txt"; DestDir: "{app}"
    
    [Code]
    function MyVersion(Param: String): String;
    var
      VersionValue: string;
      VersionFile: string;
    begin
      // Default to some predefined value.
      Result := '0.0.0';
      VersionFile := '{app}\YourVersionFile.txt';
      if LoadStringFromFile(VersionFile, VersionValue) then
        Result := VersionValue;
    end;
    

    See the help file topic "Pascal Scripting" for more information, including a list of the supported built-in functions.

提交回复
热议问题