如何正确使用 Inno Setup 中的重复函数

How to properly use duplicate functions in Inno Setup

在我的代码中重复了以下功能:(因为我使用多个代码混合不同的功能来创建我的安装程序)。

CurInstallProgressChanged

CancelButtonClick

InitializeWizard

CurPageChanged

是否可以将这些函数重命名为CancelButtonClick12(例如)等,以免出错?

此答案自 Inno Setup 6 起已过时。有关最新答案,请参阅


CurInstallProgressChangedCancelButtonClick1 必须具有该名称。您不能将它们命名为 CurInstallProgressChanged1CancelButtonClick1 并期望它们被神奇地调用。

您从 InitializeWizard 调用 InitializeWizard1InitializeWizard2。但是你不要在任何地方调用 CurInstallProgressChanged1CancelButtonClick1

如果事件函数只有一个实现,则无需在其名称后附加数字。保留 CurInstallProgressChangedCancelButtonClick.


然后,你有两个 CurPageChanged 的实现(CurPageChanged1CurPageChanged2),但是你没有主要的实现 CurPageChanged


正如 所说:

When you are reusing various feature implementations from different sources, those commonly implement the same Inno Setup event functions (like the InitializeWizard).

You have to merge these event functions as there can be just one function implementation.

You can do that by appending unique suffix to the different implementation and than calling them from a main implementation.