4

使用 InnoSetup 生成的单个可执行文件(带有“IconMain.ico”)和单个卸载(带有不同的图标“IconUninst.ico”),我想在驱动器“C”和“K”中安装一些文件。不允许用户更改驱动器路径/名称,例如:

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

我怎样才能做到这一点? 谢谢 !

4

2 回答 2

11

要有条件地安装某个文件,您需要使用该Check参数。您需要对表达式或函数返回 True 以安装项目,False 以跳过。您之前作业的示例显示在我在上一句中链接的参考页面中。

因此,要将它与custom installation type radio buttons您提到的结合起来,您只需要创建一个将分配给检查的函数,该函数将根据所选单选按钮返回其结果。

[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;
于 2012-09-08T19:37:53.713 回答
5

进行条件安装的最简单方法是使用[Types][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
于 2012-09-08T21:47:20.487 回答