I've a question about the #define in Inno Setup. I've make a setup who's working well and i'm thinking of the future of app if i have some modification to do. For example, if i change the version (Major, Minor, Build, Patch,...) i doesn't want to change all the line (like Registry) at each time.
So i try to make something like that :
#define MyAppMajor "5"
#define MyAppMinor "5"
#define MyAppBuild "1"
#define MyAppPatch "1"
...
[Files]
Source: "D:\ProgramFiles\..."; DestDir: "{app}\Program\{MyAppMajor}.{MyAppMinor}\"; Flags: ignoreversion;
[Registry]
Root: "HKLM32"; Subkey: "Software\program\"; ... ; ValueData: "{MyAppMajor}.{MyAppMinor}.{MyAppBuild}.{MyAppPatch}";
But that doesn't compile and it says :
"Unknown constant "MyAppMajor".Use two consecutive "{" characters if you are trying to embed a single "{" and not a constant".
Is there a way to do something like that for versionning or another constant ?
You missed to use the #
char (or #emit
, which is the longer version of the same), that is used to inline a defined variable into the script, e.g.:
#define MyAppMajor "5"
#define MyAppMinor "5"
#define MyAppBuild "1"
#define MyAppPatch "1"
[Files]
...; DestDir: "{app}\Program\{#MyAppMajor}.{#MyAppMinor}\"; Flags: ignoreversion;
[Registry]
...; ValueData: "{#MyAppMajor}.{#MyAppMinor}.{#MyAppBuild}.{#MyAppPatch}";
When missing this, the compiler expected (built-in) constants called MyAppMajor
, MyAppMinor
etc., whose doesn't exist; hence the error.
But, what you're trying to replicate is probably built-in in Inno Setup as the AppVersion
directive. It might be useful e.g. in conjunction of reading the version of the application binary from its included file version information:
#define AppVersion GetFileVersion('C:\MyApp.exe')
[Setup]
...
AppVersion={#AppVersion}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With