2011-12-04 41 views
0

我正在为旧游戏制作补丁(命令& Conquer 1,Win95版本),并且在某些情况下,执行补丁程序需要经过用Pascal脚本编写的函数这可能需要一段时间。现在,我在页面切换到“安装”页面的那一刻执行此操作,因此,在用户选择所有选项并确认安装之后,在安装程序启动之前,实际添加(和删除)文件。将函数执行添加到inno setup的安装程序进度中

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; 

但由于该过程可能相当长,我宁愿以某种方式将它添加到实际的安装进度栏。有什么办法可以做到这一点?

回答

5

您可以从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; 
+0

嗯。我真的应该深入到这些自定义页面。 – Nyerguds

+1

我已更新(和upvoted)您的文章有点;-) – TLama

相关问题