Inno Setup:如何在“运行"部分操作进度栏? [英] Inno Setup: How to manipulate progress bar on Run section?

查看:196
本文介绍了Inno Setup:如何在“运行"部分操作进度栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于此问题:
如何在Inno Setup安装脚本的[运行]部分中设置进度栏值?

Similar to this question:
How to set the progress bar value in the [Run] section of the Inno Setup install script?

当Inno Setup进入[Run]部分时,进度条将显示为100%,并停止在该位置.

When the Inno Setup gets to the [Run] section, the progress bar shows at 100% and stops in this position.

在此Run部分中,我安装了许多文件,我希望在安装每个程序时重新启动进度条并对其进行控制.

I have many files that I install in this Run section, which I wish to restart the progress bar and control it, as it goes installing each program.

状态消息很容易更改(StatusMsg),但是我缺少进度.你们能帮我吗?

The status message is easy to change (StatusMsg), but the progress I'm missing something. Could you guys help me out, please?

示例:

[Run]
Filename: "msiexec.exe"; Parameters: "/i ""msxml.msi"" /quiet"; \
    StatusMsg: "MSXML..."; Flags: runascurrentuser
Filename: "msiexec.exe"; Parameters: "/i ""capicom_dc_sdk.msi"" /quiet"; \
    StatusMsg: "CAPICOM..."; Flags: runascurrentuser

由于我想在安装过程中控制进度条,所以我不知道该怎么办.我想也许可以使用BeforeInstall参数,通过执行WizardForm.ProgressGauge.Position = 0;之类的代码来创建将进度条设置为0的代码,而在AfterInstall参数中,相反的是WizardForm.ProgressGauge.Position = 100;,但是如何在安装期间进行更改?

Since I want to control the progress bar during it's installation, I don't know what to do. I thought in maybe using BeforeInstall parameter, creating a code to set the progress bar to 0 by doing something like WizardForm.ProgressGauge.Position = 0; and in the AfterInstall parameter, the opposite, WizardForm.ProgressGauge.Position = 100;, but how to change during the installation?

谢谢.

推荐答案

在另一个进程正在运行的同时,更新进度条将非常困难.

It would be rather difficult to update the progress bar, while another process is running.

我看不到要这样做的地方,因为您不太可能知道子安装程序的进度,因此您不知道将进度条更新到什么.

I do not see a point of endeavoring it, as you are unlikely able to tell the progress of the sub-installer, so you won't know what to update the progress bar to.

除非特殊情况,否则子安装程序提供API报告其进度.
有关示例,请参见:

Except for special cases, when the sub-installer provides an API to report its progress.
For an example, see:

  • Inno Setup Get progress from .NET Framework 4.5 (or higher) installer to update progress bar position or
  • Inno Setup - Make Inno Setup Installer report its installation progress status to master installer.

要根据完成的子安装程序的数量更新进度条,您可以执行以下操作:

To update the progress bar according to number of sub-installers finished, you can do:

[Run]
FileName: "process1"; BeforeInstall: UpdateProgress(0); AfterInstall: UpdateProgress(33)
FileName: "process2"; AfterInstall: UpdateProgress(66)
FileName: "process3"; AfterInstall: UpdateProgress(100)

[Code]

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

要将安装文件的进度范围的一部分划分为其余部分以运行子安装程序,请参见
Inno设置-防止提取文件,将进度条设置为100%

To divide part of the progress range for installing files and the rest to running the sub-installers, see
Inno Setup - Prevent extraction of files from setting progress bar to 100%

另一个选择是使用字幕"(=无限)进度条样式.

Another option is to use a "marquee" (= infinite) progress bar style.

请参见进度栏控件样式.

[Run]
FileName: "process1"; BeforeInstall: SetMarqueeProgress(True)
FileName: "process2"
FileName: "process3"; AfterInstall: SetMarqueeProgress(False)

[Code]

procedure SetMarqueeProgress(Marquee: Boolean);
begin
  if Marquee then
  begin
    WizardForm.ProgressGauge.Style := npbstMarquee;
  end
    else
  begin
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
end;

即使不再在正式的Microsoft文档中列出,它也可以在Windows XP上运行.在Windows XP SP3上进行了测试.

Works even on Windows XP, despite not being listed in the official Microsoft documentation anymore. Tested on Windows XP SP3.

这篇关于Inno Setup:如何在“运行"部分操作进度栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆