I’m creating an installer using InnoSetup, and writing some custom handlers in a [Code] section. In one of the handlers, I would like to be able to retrieve the value of the AppName (or, potentially, the value of other parameters) defined in the [Setup] section. Is there a way for me to do this? I’ve looked though the documentation, but I haven’t found anything that would allow me to do this. Our InnoSetup files are actually generated by our build process, which stitches together fragments that are common between all of our programs and that are program specific, so it would be inconvenient to have to define constants in the code for each program. Is there any convenient way to do this?
I’m looking for something like
MyString := ExpandConstant('{AppName}');
Except {AppName} is not a defined constant. Is there some way to query for parameters defined in the [Setup] section?
It’s a build-time constant, not an install-time value. So you can use the Inno Setup Preprocessor add-on to define such constants. (You can install it easily via the QuickStart pack).
Define the constant:
Use the constant in
[Setup]:And in Pascal code, I’m not totally sure of the syntax, but something like:
Update: I realised one of my scripts uses
{#emit SetupSetting("AppId")}which is easier. Brian’s solution also discovered this method, and is better.