Inno Setup - 防止文件提取将进度条设置为 100%

Inno Setup - Prevent extraction of files from setting progress bar to 100%

在 Inno Setup wpInstalling 页面中,如何防止 [Files] 部分中定义的文件的初始提取将进度条设置为(几乎)100%?

我的安装脚本主要包括从“[运行]”部分安装一些第三方安装文件。示例如下:

[Run]
Filename: "{tmp}\vcredist_x86-2010-sp1.exe"; Parameters: "/q /norestart"; Check: InstallVCRedist;  BeforeInstall: UpdateProgress(10, 'Installing Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219...');
Filename: "{tmp}\openfire_3_8_1.exe"; Check: InstallOpenFire; BeforeInstall: UpdateProgress(25, 'Installing OpenFire 3.8.1...');
Filename: "{tmp}\postgresql-8.4.16-2-windows.exe"; Parameters: "--mode unattended --unattendedmodeui none --datadir ""{commonappdata}\PostgreSQL.4\data"" --install_runtimes 0"; Check: InstallPostgreSQL;  BeforeInstall: UpdateProgress(35, 'Installing PostgreSQL 8.4...'); AfterInstall: UpdateProgress(50, 'Setting up database...');

这些第三方组件的安装比安装的任何其他部分花费的时间都长(到目前为止),但不幸的是,在这些文件的初始提取过程中,进度条从 0% 变为接近 100%。然后,我可以使用以下过程将进度条重置为我选择的数量:

procedure UpdateProgress(Position: Integer; StatusMsg: String);
begin
  WizardForm.StatusLabel.Caption := StatusMsg;
  WizardForm.ProgressGauge.Position := Position * WizardForm.ProgressGauge.Max div 100;
end;

但理想情况下,我更喜欢初始提取而不是从 0-10%(大约),因为这将更接近实际发生的情况。

是否有任何事件可以捕获文件提取的进度,或者是否有一种方法可以防止或阻止文件提取更新进度条?

你必须增加WizardForm.ProgressGauge.Max

但不幸的是,在 Inno Setup 设置其初始最大值后没有发生任何事件。

虽然您可以滥用第一个安装文件的 BeforeInstall parameter

然后在 [Run] 部分,使用 AfterInstall 来推进栏。

这扩展了我对

的回答
[Files]
Source: "vcredist_x86-2010-sp1.exe"; DestDir: "{tmp}"; BeforeInstall: SetProgressMax(10)
Source: "openfire_3_8_1.exe"; DestDir: "{tmp}"; 

[Run]
Filename: "{tmp}\vcredist_x86-2010-sp1.exe"; AfterInstall: UpdateProgress(55);
Filename: "{tmp}\openfire_3_8_1.exe"; AfterInstall: UpdateProgress(100);
[Code]

procedure SetProgressMax(Ratio: Integer);
begin
  WizardForm.ProgressGauge.Max := WizardForm.ProgressGauge.Max * Ratio;
end;

procedure UpdateProgress(Position: Integer);
begin
  WizardForm.ProgressGauge.Position := Position * WizardForm.ProgressGauge.Max div 100;
end;