Inno Setup - Multiple software versions in one installation

て烟熏妆下的殇ゞ 提交于 2021-02-08 09:51:27

问题


I need to make a setup with multiple versions of software and i want to make it have the option for portable / install.

I have a customized components page. It should show after info page and then the directory selection page should show once the options are selected. I THINK I have the [Files] and [Tasks] and [Components] sections figured out. It's mainly the code section I am struggling with.

For example if the user selects to install the Pro version by using the radio button, once Next is clicked it should show the directory selection page and then after continuing it should install or extract (depending on portable or install selections). The installer should install/extract the specified version based on specified files marked as Pro (in the [Files] and [Components] sections).

I have tried lots of variations of code but my current variation is below and it does not work (ignore the SelectedValueIndex numbers, I have yet to put the correct value in but I wanted to make sure it would compile first). I have code for silent switches that i have to link to the radio buttons too but I think that part will work. Its literally just trying to get the selections (radio buttons and check boxes) to work. Also if you select install for one of the versions id like the group box for portable options to be greyed out (un-selectable) and vice versa. At the moment I can't get the radio buttons to have any values they just do nothing.

Simpler explanation: Lets say there are two versions of an application Free and Pro. The files that install depend on whether the user selects Free or Pro. (Set in the [Files], and [Components] Sections respectively).

procedure InitializeWizard();
var  SystemMenu: HMENU;
begin
 {Create Mode Selection Page}
    UsagePage := CreateInputOptionPage(wpInfoBefore,
   'Mode', 'Select Installation Mode',
    'Mode',
   True, False);
    UsagePage.Add('FreeInstall');
    UsagePage.Add('BusinessInstall');
    UsagePage.Add('TechnicianInstall');
    UsagePage.Add('ProfessionalInstall');
    UsagePage.Add('FreePortable');
    UsagePage.Add('BusinessPortable');
    UsagePage.Add('TechnicianPortable');
    UsagePage.Add('ProfessionalPortable');
    //
    {Set Default Checkbox - Normal Install}
    if (FreeInstall)
    then
        UsagePage.SelectedValueIndex := 1
    else
        UsagePage.SelectedValueIndex := 0;

    if (BusinessInstall)
  then
        // Set the Respective Checkbox on The Wizard.
        UsagePage.SelectedValueIndex := 1
    else
        UsagePage.SelectedValueIndex := 0;

    if (TechnicianInstall)
    then
        // Set the Respective Checkbox on The Wizard.
        UsagePage.SelectedValueIndex := 1
    else
        UsagePage.SelectedValueIndex := 0;

   if (ProfessionalInstall)
    then
        // Set the Respective Checkbox on The Wizard.
        UsagePage.SelectedValueIndex := 1
    else
        UsagePage.SelectedValueIndex := 0;
        
    {Set Default Checkbox - Portable}
    if (FreePortable)
    then
        UsagePage.SelectedValueIndex := 1
    else
        UsagePage.SelectedValueIndex := 0;

    if (BusinessPortable)
    then
        // Set the Respective Checkbox on The Wizard.
        UsagePage.SelectedValueIndex := 1
    else
        UsagePage.SelectedValueIndex := 0;

    if (TechnicianPortable)
    then
        // Set the Respective Checkbox on The Wizard.
        UsagePage.SelectedValueIndex := 1
    else
        UsagePage.SelectedValueIndex := 0;

   if (ProfessionalPortable)
    then
        // Set the Respective Checkbox on The Wizard.
        UsagePage.SelectedValueIndex := 1
    else
        UsagePage.SelectedValueIndex := 0;
    WizardForm.Caption := '{#MyAppName} v{#MyAppVersion}';
      TotalSpace;
    WizardForm.DiskSpaceLabel.Hide;

It won't compile like this


回答1:


Use Check parameter to bind [Files] section entries to the custom page selected:

[Files]
Source: "MyProgFree.exe"; DestDir: "{app}"; Check: IsModeSelected(0)
Source: "MyProgPro.exe"; DestDir: "{app}"; Check: IsModeSelected(1)

[Code]

var
  UsagePage: TInputOptionWizardPage;

function IsModeSelected(Mode: Integer): Boolean;
begin
  Result := (UsagePage.SelectedValueIndex = Mode);
end;

procedure InitializeWizard();
begin
  UsagePage :=
    CreateInputOptionPage(
      wpInfoBefore, 'Mode', 'Select Installation Mode', 'Mode', True, False);
  UsagePage.Add('FreeInstall');
  UsagePage.Add('ProInstall');
end;


来源:https://stackoverflow.com/questions/56923977/inno-setup-multiple-software-versions-in-one-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!