【问题标题】:Inno Setup - Prevent extraction of files from setting progress bar to 100%Inno Setup - 防止提取文件将进度条设置为 100%
【发布时间】:2016-03-30 16:02:11
【问题描述】:

在 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\8.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%(大约)变为更接近实际发生的情况。

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

【问题讨论】:

    标签: installation inno-setup pascalscript


    【解决方案1】:

    你必须增加WizardForm.ProgressGauge.Max

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

    你可以滥用第一个安装文件的BeforeInstall parameter

    然后在[Run] 部分中,使用AfterInstall 进行进度条。

    这扩展了我对Inno Setup: How to manipulate progress bar on Run section?的回答

    [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;
    

    【讨论】:

    • 谢谢马丁。这就像一个魅力。先生,您是圣人,也是学者。我一直很喜欢捷克人——现在更是如此。有一个标记。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多