Change AppID with [Code] just before installation in Inno Setup

In the setup, I give the user the option to install the 32-bit or 64-bit version using the switches.

Then I want to add either "_32" or "_64" to the AppID.

I know that I can change the AppID using scripting constants, but the necessary function is called when the installer starts. But at that moment the radio buttons do not exist yet, and therefore I get the error message "I can not call proc."

I turned to Inno Setup help, and I read that you can change the AppID at any time before starting the insight process (if I fit correctly).

So how do I do this?

I look forward to your answers!

+4
source share
1 answer

Some of the {code:...} functions for certain directory values ​​are called more than once, and AppId is one of them. To be more specific, it is called twice. Once before creating the wizard form and once before installation. You can simply check if the checkbox from which you want to get the value exists. You can simply ask if this is Assigned like this:

 [Setup] AppId={code:GetAppID} ... [Code] var Ver32RadioButton: TNewRadioButton; Ver64RadioButton: TNewRadioButton; function GetAppID(const Value: string): string; var AppID: string; begin // check by using Assigned function, if the component you're trying to get a // value from exists; the Assigned will return False for the first time when // the GetAppID function will be called since even WizardForm not yet exists if Assigned(Ver32RadioButton) then begin AppID := 'FDFD4A34-4A4C-4795-9B0E-04E5AB0C374D'; if Ver32RadioButton.Checked then Result := AppID + '_32' else Result := AppID + '_64'; end; end; procedure InitializeWizard; var VerPage: TWizardPage; begin VerPage := CreateCustomPage(wpWelcome, 'Caption', 'Description'); Ver32RadioButton := TNewRadioButton.Create(WizardForm); Ver32RadioButton.Parent := VerPage.Surface; Ver32RadioButton.Checked := True; Ver32RadioButton.Caption := 'Install 32-bit version'; Ver64RadioButton := TNewRadioButton.Create(WizardForm); Ver64RadioButton.Parent := VerPage.Surface; Ver64RadioButton.Top := Ver32RadioButton.Top + Ver32RadioButton.Height + 4; Ver64RadioButton.Caption := 'Install 64-bit version'; end; 
+8
source

All Articles