Using {AppVersion} as a parameter for a function in Inno Setup

So, I have a function that updates some XML, and I would like to pass the {AppVersion} that was set in the [Setup] part of the script as a constant for this function

I tried

 MyFunction(ExpandConstants({AppVersion}) 

But does this give me a mistake? How to pass this constant to my function correctly

My code

 [Files] Source: ".\Source\myfile.txt"; DestDir: "{app}\System"; AfterInstall: MyFunction('{#SetupSetting("AppVersion")}') [Setup] AppId=MyApp AppName=My Application AppVersion=011 DefaultDirName=C:\MyApp [Code] procedure MyFunction(Text: String); begin MsgBox(Text, mbInformation, MB_OK); end; 
+5
source share
1 answer

Use the SetupSetting preprocessor SetupSetting to extend the [Setup] values โ€‹โ€‹of the section directive:

 MyFunction('{#SetupSetting("AppVersion")}'); 

Short term evidence:

 [Setup] AppName=My Program AppVersion=1.2.3.4 DefaultDirName={pf}\My Program [Code] procedure InitializeWizard; begin MsgBox('AppVersion is: {#SetupSetting("AppVersion")}.', mbInformation, MB_OK); end; 
+7
source

Source: https://habr.com/ru/post/1206341/


All Articles