Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

So I have a function that is updating some XML and I would like to pass the {AppVersion} that has been set in the [Setup] part of the script as a constant to this function

I have tried

MyFunction(ExpandConstants({AppVersion})

But this gives me an error? How do I 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;
like image 795
User1 Avatar asked Nov 06 '14 12:11

User1


1 Answers

Use the SetupSetting preprocessor function for expanding [Setup] section directive values:

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

A short proof:

[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;
like image 54
TLama Avatar answered Nov 08 '22 17:11

TLama