简体   繁体   English

将功能执行添加到inno设置的安装程序进度中

[英]Add function execution into installer progress of inno setup

I'm making a patch for an old game (Command & Conquer 1, Win95 edition), and in some cases, executing the patch requires going through a function written in the Pascal script that could take quite a while. 我正在为旧游戏(《命令与征服1》,Win95版)制作补丁,在某些情况下,执行补丁需要经过Pascal脚本编写的函数,这可能需要一段时间。

At the moment, I execute this at the moment the page is changed to the "installing" page, so, after the user has selected all options and confirmed to install, right before the installer starts actually adding (and deleting) files. 此刻,我将在页面更改为“正在安装”页面时执行此操作,因此,在用户选择了所有选项并确认安装后,即在安装程序开始实际添加(和删除)文件之前。

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;

But since the process could be rather long, I'd prefer to somehow add it to the actual install progress bar. 但是由于过程可能会很长,所以我宁愿以某种方式将其添加到实际的安装进度栏中。 Is there any way to accomplish this? 有什么办法可以做到这一点?

You can control the ProgressGauge from the install page of the WizardForm . 您可以从WizardForm的安装页面控制ProgressGauge In the following script is shown how to update the progress bar from a loop (which you'll just replace with your actions). 在下面的脚本中,显示了如何从循环更新进度条(您将用操作将其替换)。 For safety are progress bar values like min, max and position saved before the custom actions are performed and restored when they're done. 为了安全起见,应在执行自定义操作之前保存进度栏值(例如最小值,最大值和位置),并在完成后将其还原。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM