【问题标题】:Inno Setup - Define Disk Space by componentInno Setup - 按组件定义磁盘空间
【发布时间】:2016-03-01 23:05:17
【问题描述】:

默认情况下,在组件页面上,Inno Setup 会将内部所有文件的大小添加到所选组件的大小(显示在页面底部)。

现在,我特别需要 Inno Setup 来要求与当前组件的大小完全相同。我怎样才能做到这一点?

新代码:

[Setup]
AppName=Dagon Video Tools
AppVersion=1.0
AppVerName=Dagon Video Tools
DefaultDirName={sd}\Tools\Dagon Video Tools
VersionInfoProductName=Dagon Video Tools
WizardImageFile=Include\WizardImage.bmp
WizardSmallImageFile=Include\WizardSmallImage.bmp
SetupIconFile=Include\Icon.ico

[Files]
.....

[ThirdParty]
UseRelativePaths=True

[Components]
Name: "Slasher"; Description: "Dagon Slasher"; Types: Slasher Full
Name: "Frankenstein"; Description: "Dagon Frankenstein"; Types: Frankenstein Full

[Types]
Name: "Full"; Description: "Full"
Name: "Slasher"; Description: "Dagon Slasher"
Name: "Frankenstein"; Description: "Dagon FrankenStein"

[Icons]
Name: "{group}\{cm:UninstallProgram,Dagon Slasher}"; Filename: "{uninstallexe}"; Components: Slasher
Name: "{group}\{cm:UninstallProgram,Dagon Frankenstein}"; Filename: "{uninstallexe}"; Components: Frankenstein
Name: "{group}\{cm:UninstallProgram,Dagon Video Tools}"; Filename: "{uninstallexe}"; Components: Slasher and Frankenstein


[Code]
procedure CurPageChanged(CurPageID: Integer);
Begin
if (CurPageID=wpSelectProgramGroup) then
  begin
  if IsComponentSelected('Slasher') then
    begin
      WizardForm.DirEdit.Text := ExpandConstant('{sd}\Tools\Dagon Slasher');
      WizardForm.GroupEdit.Text := 'Dagon Slasher';
    end;
  if IsComponentSelected('Frankenstein') then
    begin
      WizardForm.DirEdit.Text := ExpandConstant('{sd}\Tools\Dagon FrankenStein');
      WizardForm.GroupEdit.Text := 'Dagon FrankenStein';
    end;
  if IsComponentSelected('Slasher') and IsComponentSelected('Frankenstein') then
    begin
      WizardForm.GroupEdit.Text := 'Dagon Video Tools';
    end
  end;
End;

procedure OnTypeChange(Sender: TObject);
begin
  // set the item index in hidden TypesCombo
  WizardForm.TypesCombo.ItemIndex := TNewCheckListBox(Sender).ItemIndex;
  // notify TypesCombo about the selection change
  WizardForm.TypesCombo.OnChange(nil);
end;

procedure InitializeWizard;
var
  I: Integer;
  CheckListBox: TNewCheckListBox;
begin
  // create the TNewCheckListBox object and set the basic properties
  CheckListBox := TNewCheckListBox.Create(WizardForm);
  CheckListBox.Parent := WizardForm.SelectComponentsPage;
  CheckListBox.Left := WizardForm.TypesCombo.Left;
  CheckListBox.Top := WizardForm.TypesCombo.Top;
  CheckListBox.Width := WizardForm.TypesCombo.Width;
  CheckListBox.Height := CheckListBox.MinItemHeight * 
    WizardForm.TypesCombo.Items.Count + 4;
  CheckListBox.TabOrder := 0;
  // assign the selection change event
  CheckListBox.OnClickCheck := @OnTypeChange;
  // add radio buttons from all TypesCombo items, select the first item
  for I := 0 to WizardForm.TypesCombo.Items.Count - 1 do
    CheckListBox.AddRadioButton(WizardForm.TypesCombo.Items[I], 
      '', 0, I = 0, True, nil);
  // hide the TypesCombo combo box
  WizardForm.TypesCombo.Visible := False;
  WizardForm.ComponentsList.Visible := False;
  WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;

发布了完整的代码,因为如您所见,我的代码会根据组件更改{app}{group}。我现在要上班了,所以下半天不上网。这段代码似乎显示了正确的文件大小,我打算使用附加到组件选择的其他一些功能,所以,如果这可行,我将不得不发布另一个问题。大约 8 小时后回来。

【问题讨论】:

  • 好的,我定义了每个组件的大小(ExtraDiskSpaceRequired),但是对于 Inno 来说它是额外空间,所以,当显示所需的磁盘空间时,Inno 实际上显示了打包在里面的所有文件的大小 + 大小的组件。我需要 Inno 忽略其中文件的大小,并且需要与当前组件一样多的磁盘空间。
  • 那么为什么不将ExtraDiskSpaceRequired 设置为字节数以将文件的大小增加到您需要的大小呢?嗯,实际上这就是参数的用途。
  • 好的,问题是它是一个两部分的程序。安装程序应该只允许安装一个程序,或者另一个,或者“完整包”。因此,其中 2 个组件的大小小于所有文件。而“全包”已经是全尺寸了。显然,选择“完整包”会显示所需磁盘空间量的两倍。因此,任何组件的大小都不会在任何东西上“加满”,它应该减小。
  • 是一个组件,但是三个组件都是独占的

标签: inno-setup pascalscript


【解决方案1】:

您使用的设置组件不正确。您的“完整包” 组件不是组件。它是两个组件的组合(“第 1 部分” + “第 2 部分”)。结果,内置的 Inno Setup 逻辑与您的安装程序不匹配,现在您询问如何解决这个问题。不要尝试解决这个问题,而是正确使用 Inno Setup。

你想要的是两个组件:

  • 第 1 部分
  • 第 2 部分

以及三种设置类型:

  • 完整包(安装 “Part 1”“Part 2” 组件)
  • 第 1 部分(仅安装 “第 1 部分” 组件)
  • 第 2 部分(仅安装 “第 2 部分” 组件)

如果您使用组件而不是类型,因为您更喜欢“单选按钮”选择而不是组合框(下拉菜单),请参阅Replace installation types Dropdown list by radio buttons

这样您可以获得与屏幕截图相同的 GUI,但可以正常工作。

在您的情况下,显示组件列表可能根本没有意义。确保没有类型具有 iscustom 标志来隐藏组件列表并确保它选择正确的组件(iscustom 类型不选择它们的组件)。

如果您仍然想显示尺码标签,请明确显示:

procedure InitializeWizard();
begin
  WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;

如果您想显示没有自定义类型的组件列表:

procedure InitializeWizard();
begin
  WizardForm.ComponentsList.Visible := True;
  WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;

【讨论】:

  • 那仍然没有显示正确的文件大小...在这种情况下我可以禁用磁盘空间要求吗?虽然,这仍然不理想。
  • 从使用 Inno 的第一天起,我就远离那些可怕的类型。 “完整”类型不显示组合文件大小,如果我切换到另一种类型然后返回“完整”...
  • 是的,对不起。我得去上班了,所以我有点着急。我不是关于类型的第一件事。我下班回来,发截图(不知道怎么在cmets里贴代码,所以也截图)
  • 非常感谢,马丁。当然,它有效,我只需要阅读一点关于类型及其工作原理的内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-29
  • 1970-01-01
  • 2020-07-12
  • 1970-01-01
相关资源
最近更新 更多