【问题标题】:Add function execution into installer progress of inno setup将功能执行添加到 inno setup 的安装程序进度中
【发布时间】:2011-12-04 10:23:50
【问题描述】:

我正在为一个老游戏(命令与征服 1,Win95 版)制作补丁,在某些情况下,执行补丁需要通过一个用 Pascal 脚本编写的函数,这可能需要相当长的时间。

目前,我在页面更改为“安装”页面时执行此操作,因此,在用户选择所有选项并确认安装之后,就在安装程序开始实际添加(和删除)文件之前.

procedure CurPageChanged(CurPageID: Integer);
begin
    if (CurPageID = wpInstalling) then
    begin
        // Rename all saveg_hi.### files to savegame.###
        renameSaveGames();
        // clean up the ginormous files mess left behind if the game was installed from the 'First Decade' compilation pack
        cleanupTFD();
    end;
end;

但由于该过程可能相当长,我更愿意以某种方式将其添加到实际安装进度条中。有没有办法做到这一点?

【问题讨论】:

    标签: installation progress-bar inno-setup pascalscript


    【解决方案1】:

    您可以从WizardForm 的安装页面控制ProgressGauge。以下脚本显示了如何从循环中更新进度条(您只需将其替换为您的操作)。为安全起见,在执行自定义操作之前保存进度条值,例如最小值、最大值和位置,并在完成后恢复。

    [Code]
    procedure CurPageChanged(CurPageID: Integer);
    var
      I: Integer;
      ProgressMin: Longint;
      ProgressMax: Longint;
      ProgressPos: Longint;
    begin
      if CurPageID = wpInstalling then
      begin
        // save the original "configuration" of the progress bar
        ProgressMin := WizardForm.ProgressGauge.Min;
        ProgressMax := WizardForm.ProgressGauge.Max;
        ProgressPos := WizardForm.ProgressGauge.Position;
    
        // output some status and setup the min and max progress values
        WizardForm.StatusLabel.Caption := 'Doing my own pre-install...';
        WizardForm.ProgressGauge.Min := 0;
        WizardForm.ProgressGauge.Max := 100;
        // here will be your time consuming actions with the progress update
        for I := 0 to 100 do
        begin
          WizardForm.FilenameLabel.Caption := 'I''m on ' + IntToStr(I) + '%';
          WizardForm.ProgressGauge.Position := I;
          Sleep(50);
        end;
    
        // restore the original "configuration" of the progress bar
        WizardForm.ProgressGauge.Min := ProgressMin;
        WizardForm.ProgressGauge.Max := ProgressMax;
        WizardForm.ProgressGauge.Position := ProgressPos;
      end;
    end;
    

    【讨论】:

    • 嗯。我真的应该深入研究那些自定义页面。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-11
    • 1970-01-01
    • 2010-11-06
    • 2017-04-18
    • 2018-05-20
    相关资源
    最近更新 更多