Nevvyn PieEater.
Nevvyn PieEater.

Reputation: 33

Ask user for the version of application to modify and change installation folder accordingly using Inno Setup

I'm trying to use Inno Setup to install some custom skins for DCS. I would like to ask the user the version of DCS they have installed (and potentially check the registry or file path first to see if there is more than one version installed) and then ask the user to pick the one they want to install it to.

Or, potentially all of them.

For example, if DCS, DCS Beta and DCS Steam are installed, provide checkboxes to install to all of them, or just one..

Or if easier, just a radial choice at the beginning.. Can anyone help with the CODE section of Inno setup, or advise how you can set a variable from the code section?

Upvotes: 2

Views: 101

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202584

Create a custom page for the selection (e.g. using CreateInputOptionPage). When the user clicks its Next button, update the destination directory accordingly.

[Code]
var
  VersionSelectionPage: TInputOptionWizardPage;
  
procedure InitializeWizard();
begin
  VersionSelectionPage :=
    CreateInputOptionPage(wpInfoBefore, 'Version selection', '', '', True, False);
  VersionSelectionPage.Add('1.0');
  VersionSelectionPage.Add('2.0');
  VersionSelectionPage.Add('3.0');
  VersionSelectionPage.SelectedValueIndex := 0;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
  Dir: string;
begin
  if CurPageID = VersionSelectionPage.ID then
  begin
    case VersionSelectionPage.SelectedValueIndex of
      0: Dir := ExpandConstant('{pf}\My Program v1');
      1: Dir := ExpandConstant('{pf}\My Program v2');
      2: Dir := ExpandConstant('{pf}\My Program v3');
      else RaiseException('Unexpected selection');
    end;
    WizardForm.DirEdit.Text := Dir;
  end;
  Result := True;
end;

Upvotes: 1

Related Questions