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 th
Inspired by Craig's answer, I was looking at the Inno Setup Preprocessor documentation (in ISTool, not available online as far as I've found), and came across the SetupSetting
function in the preprocessor.
It can be used as so:
MyString := '{#SetupSetting("AppName")}';
And as long as the [Setup]
section appears before the place where this is used (ISPP seems to be only one pass), and includes a definition for AppName
, this will give the results I want, without having to define an extra macro for each setting we want to extract.
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:
#define AppName "Excellent Foo App"
Use the constant in [Setup]
:
AppName={#AppName}
And in Pascal code, I'm not totally sure of the syntax, but something like:
MyString := {#AppName}
Update: I realised one of my scripts uses {#emit SetupSetting("AppId")}
which is easier. Brian's solution also discovered this method, and is better.