Kir*_*ira 5 dll inno-setup inno-setup-v6
我们目前使用 Inno Setup 5.5.3 版来构建安装程序。我打算将此版本升级到 6.1.2。
我们使用 Inno Setup 来安装我们的产品。我们随安装程序一起提供许可证代码,用户在安装过程中在字段中输入许可证。此许可证使用自定义 DLL 进行验证,并且 DLL 为有效许可证返回非否定结果。此过程在 5.5.3 和 5.6.1 中运行良好,但在版本 6 中失败(使用 6.0.5 和 6.1.2 测试)。
不幸的是,没有生成指出确切问题的日志。
这个自定义 DLL 是 32 位的,是在 10 多年前使用 C++ 构建的。没有计划重做这部分。有没有办法使用相同的 DLL 并解决问题?谢谢你。
[Files]
Source: mydll.dll; Flags: dontcopy
Run Code Online (Sandbox Code Playgroud)
[Files]
Source: mydll.dll; Flags: dontcopy
Run Code Online (Sandbox Code Playgroud)
// This function calls the external mydll which parses licenseCode and
// returns an integer
function getFlags( secret, licenseCode : String) : Integer;
external 'getFlags@files:mydll.dll cdecl';
Run Code Online (Sandbox Code Playgroud)
function checkLicense(license : String) : Boolean;
var
secret : String;
begin
Result := False; // default is Incorrect license
license := Trim(license);
secret := <secret>
// This line calls the above getFlags function and expects to get an integer
license_flags := getFlags( secret, license);
if license_flags = -1 then begin
if not suppressMsgBox then begin
MsgBoxLog( ‘Incorrect License’)
end;
Exit;
end;
Result := True;
end;
Run Code Online (Sandbox Code Playgroud)
这不是 5.x 与 6.x 的问题,也不是位数问题。这是 Ansi 与 Unicode 的问题。
在 5.x 中,有两个版本的 Inno Setup,Ansi 版和 Unicode 版。您可能使用的是 Ansi 版本,并且您的代码是为它设计的。在 6.x 中,只有 Unicode 版本。您的代码在 Unicode 版本中不起作用。通过升级到 6.x,您无意中也从 Ansi 升级到了 Unicode。
一个快速而肮脏的解决方案是更改getFlags函数的声明以正确声明参数为 Ansi 字符串(AnsiString类型):
function getFlags( secret, licenseCode : AnsiString) : Integer;
external 'getFlags@files:mydll.dll cdecl';
Run Code Online (Sandbox Code Playgroud)
正确的解决方案是重新实现您的 DLL 以使用 Unicode 字符串(wchar_t指针):
PS_EXPORT(int) getFlags( const wchar_t * secret, const wchar_t * license )
Run Code Online (Sandbox Code Playgroud)
这是一个类似的问题:Inno Setup Calling DLL with string as parameter。
另请参阅从 Ansi 升级到 Inno Setup 的 Unicode 版本(任何缺点)。
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |