你能帮我创建基于DLL文件的串行检查函数吗? 不幸的是我没有函数原型(prototype)。
我拥有的是该函数的 NSIS 版本:
SetOutPath $PLUGINSDIR
File "serialtest.dll"
System::Call "serialtest::_sn_serialtest(t r1) i .r2 ?u"
${If} $2 == 0
Messagebox MB_OK|MB_ICONSTOP \
"Invalid Serial Number!"
Abort
${Endif}
t
- 文本,字符串(LPCSTR,指向第一个字符的指针)
r1-r9
- NSIS 的这些是 $1-$9(可以是输入或输出)。在本例中,r1 是 $1,$1 是带有分隔符“-”的序列号。
i
- int(包括字符、字节、短整型、句柄、指针等)
.
- 表示没有输入
u
- 卸载 DLL
附加信息:NSIS 脚本是用 ANSI 编写的,我使用的是 Inno Setup 的 Unicode 版本。
如果可能,应从编辑框导入序列号 - 我在这里提出了有关自定义序列页的问题:CustomPage for Serial Number in Inno Setup
最佳答案
我根本不了解NSIS,所以以下只是脚本解释的尝试:
serialtest::_sn_serialtest(t r1) i .r2 ?u
我是这样理解的:
serialtest.dll - is the library, where the function is imported from
t - the input string typed as LPCSTR
i - integer result put into the no input variable (so just output variable)
所以你的原型(prototype)可能看起来像这样:
int _sn_serialtest(
__in LPCSTR sn
);
我在这里缺少的是一些调用约定符号,所以下面的原型(prototype)可能不起作用,如果你知道该库是用 C 编写的(我在 Google 上搜索过的大多数 NSIS 插件是什么),那么它可能是cdecl,如下所示,但这只是我的猜测,可能会有所不同:
function _sn_serialtest(sn: AnsiString): Integer;
external '_sn_serialtest@files:serialtest.dll cdecl';
关于prototype - 使用独立 DLL 文件验证串行 key - 转换函数 NSIS => Prototype => Pascal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10479398/