通过 #Include 指令扩展事件函数
我有一个基本的 inno-setup 脚本,用作多个安装程序的模板。作为基本脚本的一部分,我调用了事件函数 NextButtonClick
。
我现在想向 NextButtonClick
事件添加一些额外的代码,该代码仅由我的一个安装程序执行。有什么方法可以“扩展” NextButtonClick
事件吗?我正在考虑类似于 Python 的 super()
函数。
Inno-setup 使用 Pascal 作为脚本语言,因此也许 Pascal 专家可以提供一些见解。
I have a base inno-setup script that I use as a template for several installers. As part of the base script I have a call to the event function, NextButtonClick
.
I would now like to add some additional code to the NextButtonClick
event that will only be executed by one of my installers. Is there some way to "extend" the NextButtonClick
event? I'm thinking of something along the lines of Python's super()
function.
Inno-setup uses Pascal as a scripting language, so perhaps a Pascal expert can offer some insight.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不直接
记住#include指令只是一个预编译器指令,它使包含的文件出现在inno安装脚本编译器的指令所在的位置。
但是
为了避免在模板脚本中包含单独的安装程序代码,您可以创建一个约定来调用模板中的过程。
您必须遵循的唯一规则是每个安装程序都必须声明该过程,即使是空白。这样,您可以根据每个安装程序进行自定义,同时保持中性模板。
你的模板可能是这样的:
那么各个安装程序可能看起来像这样:
也许可以实现一种复杂的方法,我只是不记得 PascalScript 是否支持过程类型,并且没有时间检查 inno。
免责声明所有代码直接写在这里向您展示想法,它可能无法编译。
Not directly
Remember the #include directive is just a pre-compiler directive which makes the included file to appear in the place the directive is to the inno setup script compiler.
but
To avoid including individual installer code on the template script, you can create a convention to call a procedure in the template.
The only rule you have to follow is that every installer must declare the procedure, even blank. That way, you can customize as per-installer basis while maintaining a neutral template.
Your template may be something like:
Then individual installers may look like this:
Maybe it is possible to implement a complex approach, I just can't remember if PascalScript supports procedural types and no time to check with inno.
disclaimer all code written directly here to show you the idea, it may not compile.
我正在使用以下解决方法,这可能会使事情最终难以管理,但使用版本控制,我现在可以控制它:
在我的个人安装程序中,我有一系列
#define< /code> 指令。例如:
然后在我的基本模板中,我使用
#ifdef
指令选择性地在 Pascal 脚本事件中包含不同的代码片段:这种方法的一个缺点是基本模板会慢慢地编写代码填写真正属于各个安装程序的代码。但是,由于这些是编译时指令,因此生成的安装可执行文件不应变得臃肿。
但实际上,我对这种方法最大的问题是它感觉不像 The Right Way™。
I'm using the following workaround, which may make things hard to manage eventually, but using version control I'm able to keep a handle on it for now:
In my individual installers, I have a series of
#define
directives. For example:Then in my base template, I use the
#ifdef
directives to optionally include different pieces of code within the Pascal scripting events:The one downside to this approach is that code that the base template will slowly fill up with code that really belongs with the individual installer. However, since these are compile time directives, the resulting setup executables should not get bloated.
Really, though, my biggest problem with this approach is that it just doesn't feel like The Right Way™.