3
votes

With a single executable file generated with InnoSetup (with "IconMain.ico") and a single uninstall(with a different icon "IconUninst.ico"), I would like to install some files in drive "C" and "K". The user will not be allowed to change drive paths/names, as :

STANDART RADIOBUTTON - 
Full installation. Files that will be installed in drive "C:" AND "K:"

- Game.exe     --> DRIVE C:\games
- Mapping.exe  --> DRIVE C:\Mapping
- Pics.dll     --> DRIVE C:\Pics 
- AAA.dll      --> DRIVE K:\Sounds
- BBB.obj      --> DRIVE K:\Sounds

'

ADVANCED RADIONBUTTON -
Partial installation. 
The only files that will be installed. (IF user agrees to continue)

- AAA.dll      --> DRIVE K:\Sounds
- BBB.obj      --> DRIVE K:\Sounds

How can I accomplish that? Thank you !

2
@TLama : I have read your article [stackoverflow.com/questions/11718831/… and this is exactly I was looking for. However I cannot combine that to some other examples I found on the net. Can you or anyone be so kind to complete the code following my above needs? -->There would be a single installer.exe, a single unistaller.exe and the users would not be able to change drive location. - Luiz Vaughan
Yep, I'm here :-) Right now I've been thinking about your previous assignment and that would be more complicated. The current way after update will be pretty easy. I'll be right back... - TLama

2 Answers

10
votes

To conditionally install a certain file you need to use the Check parameter. You need to return True to the expression or function to install the item, False to skip. The example to your previous assignment is shown in the reference page I've linked in the previous sentence.

So to combine it with custom installation type radio buttons you've mentioned, you just need to make a function that will be assigned to the check and that will return its result depending on selected radio button.

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Files]
; these two items will be installed always
Source: "AAA.dll"; DestDir: "K:\Sounds"
Source: "BBB.obj"; DestDir: "K:\Sounds"
; these three items will be installed only when the IsFullInstallation
; function returns True, what will depend on the selected radio button
Source: "Game.exe"; DestDir: "C:\Games"; Check: IsFullInstallation;
Source: "Mapping.exe"; DestDir: "C:\Mapping"; Check: IsFullInstallation;
Source: "Pics.dll"; DestDir: "C:\Pics"; Check: IsFullInstallation;

[Code]    
const
  FullDescText =
    'Full installation. Files will be installed on drives "C:" and "K:"';
  PartDescText =
    'Partial installation. Files will be installed on drives "C:" and "K:"';

var
  FullRadioButton: TNewRadioButton;
  PartRadioButton: TNewRadioButton;

procedure InitializeWizard;
var
  CustomPage: TWizardPage;
  FullDescLabel: TLabel;
  PartDescLabel: TLabel;
begin
  CustomPage := CreateCustomPage(wpWelcome, 'Installation type', '');
  FullRadioButton := TNewRadioButton.Create(WizardForm);
  FullRadioButton.Parent := CustomPage.Surface;
  FullRadioButton.Checked := True;
  FullRadioButton.Top := 16;
  FullRadioButton.Width := CustomPage.SurfaceWidth;
  FullRadioButton.Font.Style := [fsBold];
  FullRadioButton.Font.Size := 9;
  FullRadioButton.Caption := 'Full Installation'
  FullDescLabel := TLabel.Create(WizardForm);
  FullDescLabel.Parent := CustomPage.Surface;
  FullDescLabel.Left := 8;
  FullDescLabel.Top := FullRadioButton.Top + FullRadioButton.Height + 8;
  FullDescLabel.Width := CustomPage.SurfaceWidth; 
  FullDescLabel.Height := 40;
  FullDescLabel.AutoSize := False;
  FullDescLabel.Wordwrap := True;
  FullDescLabel.Caption := FullDescText;
  PartRadioButton := TNewRadioButton.Create(WizardForm);
  PartRadioButton.Parent := CustomPage.Surface;
  PartRadioButton.Top := FullDescLabel.Top + FullDescLabel.Height + 16;
  PartRadioButton.Width := CustomPage.SurfaceWidth;
  PartRadioButton.Font.Style := [fsBold];
  PartRadioButton.Font.Size := 9;
  PartRadioButton.Caption := 'Partial Installation'
  PartDescLabel := TLabel.Create(WizardForm);
  PartDescLabel.Parent := CustomPage.Surface;
  PartDescLabel.Left := 8;
  PartDescLabel.Top := PartRadioButton.Top + PartRadioButton.Height + 8;
  PartDescLabel.Width := CustomPage.SurfaceWidth;
  PartDescLabel.Height := 40;
  PartDescLabel.AutoSize := False;
  PartDescLabel.Wordwrap := True;
  PartDescLabel.Caption := PartDescText;
end;

function IsFullInstallation: Boolean;
begin
  Result := FullRadioButton.Checked;
end;
4
votes

The easiest way to make conditional installations is to use [Types] and [Components].

[Types]
Name: standard; Description: Standard
Name: partial; Description: Partial

[Components]
Name: game; Description: Full game install; Types: standard
Name: sounds; Description: Sound files; Types: standard partial

[Files]
...; Components: game
...; Components: sounds