我可以在Inno Setup中创建自己的课程或单位吗? [英] Can I create my own classes or units in Inno Setup?
问题描述
我想知道在Inno安装程序中是否可以定义我自己的单位或类 - 两个字段(就像定义一个记录一样)和方法。
- 结构(
record
keyword) - 仅字段和
- 接口(
interface
关键字) - 仅适用于COM / ActiveX
但不能实现类(字段和方法)。
Pascal脚本甚至不识别 class
关键字。
甚至单位
。 Inno Setup Pascal脚本只是一个单独的代码块。没有真正的任何点试图隐藏一些实现/代码。
如果您只是想以某种方式整理程式码,可以使用 #include
指令 Inno Setup预处理器将代码拆分成文件。
类似标题/接口的文件,其中包含公共函数/过程的原型/转发声明以及类似实现的文件实现和私有函数/过程。
类接口文件(例如 header.iss
):
procedure PublicProc;前锋;
类似实现的文件(例如 impl.iss
):
过程PrivateProc;
begin
...
end;
过程PublicProc;
begin
PrivateProc;
end;
并使用它:
[代码]
#includeheader.iss
函数InitializeSetup:Boolean;
begin
//这里我们可以使用PublicProc,但不能使用PrivateProc
end;
#includeimpl.iss
I would like to know if it's possible in Inno Setup to define my own units or classes - with both fields (just like defining a record) and methods.
No, you can define only:
- structures (
record
keyword) - fields only, and - interfaces (
interface
keyword) - abstract methods only - for COM/ActiveX.
But you cannot implement classes (fields and methods).
The Pascal Script does not even recognize the class
keyword.
Not even unit
s. The Inno Setup Pascal Script is just a single block of code. There's no really any point trying to hide some implementation/code.
If you just want to organize the code somehow, you can use the #include
directive of Inno Setup pre-processor to split the code into files.
You can have a header/interface-like file with prototypes/forward declarations of the "public" functions/procedures and implementation-like file with the implementation and "private" functions/procedures.
The interface-like file (say header.iss
):
procedure PublicProc; forward;
The implementation-like file (say impl.iss
):
procedure PrivateProc;
begin
...
end;
procedure PublicProc;
begin
PrivateProc;
end;
And use it like:
[Code]
#include "header.iss"
function InitializeSetup: Boolean;
begin
// Here we can use the PublicProc, but not PrivateProc
end;
#include "impl.iss"
这篇关于我可以在Inno Setup中创建自己的课程或单位吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!