InnoSetup: Getting AppName in [Code] section

前端 未结 2 1952
我在风中等你
我在风中等你 2020-12-24 13:30

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

2条回答
  •  孤城傲影
    2020-12-24 14:23

    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.

提交回复
热议问题