Inno Setup 5.5.4(a)在Windows 7下有错误"无法导入dll"

时间:2014-05-17 09:29:27

标签: windows-7 inno-setup dllimport

我需要使用几个dll来做一个serup应用程序: 在pas脚本中使用compinstkey.dll调用aspr_ide.dll。 我在iss-script中做了:

[Files]
Source: aspr_ide.dll; DestDir: {app};Flags: ignoreversion
Source: CompInstKey.dll; DestDir: {app}; Flags: ignoreversion
....
[Code]
....
function GetRegistrationKeys: PAnsiChar;
external 'GetRegistrationKeys@files:aspr_ide.dll stdcall';

procedure Installinfo(ApplicationName, Version, UserName, Key: PAnsiChar);
  external 'Installinfo@files:CompInstKey.dll stdcall';
....
function InitializeSetup: Boolean;

begin
 Result := False;
 ExtractTemporaryFile('aspr_ide.dll');
 ExtractTemporaryFile('CompInstKey.dll');
end;
.....

在Windows XP中它可以正常工作,但是Windows7会抛出错误"无法导入dll:C:... \ Temp \ tp.GHPtmp \ aspr_ide.dll"。在安装暂停时,此时的aspr_ide.dll存在于" C:... \ Temp \ tp.GHPtmp \"。

我错了什么?为什么不在Windows 7下运行?我该如何纠正?

2 个答案:

答案 0 :(得分:0)

您应该在函数声明中使用delayload关键字,例如:

function GetRegistrationKeys: PAnsiChar;
external 'GetRegistrationKeys@files:aspr_ide.dll stdcall delayload';

procedure Installinfo(ApplicationName, Version, UserName, Key: PAnsiChar);
  external 'Installinfo@files:CompInstKey.dll stdcall delayload';

delayload导致安装程序仅在调用DLL时加载DLL,而不是在http://www.jrsoftware.org/ishelp/index.php?topic=scriptdll中记录的启动时加载DLL。

答案 1 :(得分:0)

首先,我建议您将Inno更新到版本5.5.9,其中错误最少。其次,在Win7系统上重新编译DLL,因为在XP和Win7依赖的动态库中DLL可能不一样。