Inno安装程序无法导入DLL [英] Inno Setup failing to import DLL

查看:466
本文介绍了Inno安装程序无法导入DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有将Delphi DLL导入Inno Setup(Unicode)的任何运气. DLL有一个简单的过程.

I'm not having any luck importing a Delphi DLL into Inno Setup (Unicode). The DLL has a simple procedure..

procedure Foo(); stdcall;
begin

end;

exports
  Foo;

该DLL包含在安装程序源中,并添加到文件列表中:

The DLL is included in the installer source, and added to the files list:

[Files]
Source: "MyDLL.dll"; Flags: dontcopy

然后,我在初始化中提取此DLL:

Then, I extract this DLL in the initialization:

function InitializeSetup(): Boolean;
begin
  ExtractTemporaryFile('MyDLL.dll');
end;

最后,在脚本中声明了此过程:

And finally, declared this procedure in the script:

function DoFoo(): Bool;
  external 'Foo@MyDLL.dll stdcall';

但是,当我运行安装程序时,出现错误:

However, when I run the setup, I get an error:

Cannot Import dll: <utf8>MyDLL.dll.

我在做什么错了?

推荐答案

由于您没有在函数导入中使用延迟加载,因此Inno Setup加载程序由于未找到您的库而无法运行.这是因为在触发InitializeSetup事件之前执行了是否可以使用函数导出的操作,因此还没有从存档中提取您的库.

Since you haven't used delayed loading in your function import, Inno Setup loader failed to run because it didn't found your library. That's because checks whether function exports are available are performed before the InitializeSetup event is fired and so your library was not yet extracted from the archive.

在您的情况下,请以正确的方式添加 delayload 导入选项.但是,如果在库文件名之前添加files:前缀,则可以省略手动提取,并告诉安装程序为您提取库.此前缀为 documented 如下:

In your case is adding delayload import option the right way. But you can omit manual extracting and tell the installer to extract the library for you if you add files: prefix before the library file name. This prefix is documented as:

在安装过程中,特殊的"files:"前缀也可用于指示 设置为从[文件]自动提取一个或多个DLL. 在加载第一个DLL之前.

During Setup, a special 'files:' prefix may also be used to instruct Setup to automatically extract one or more DLLs from the [Files] section before loading the first DLL.

您的情况下,整个导入可以缩短为:

The whole import in your case can be then shortened to:

[Files]
Source: "MyDLL.dll"; Flags: dontcopy

[Code]
procedure Foo;
  external 'Foo@files:MyDLL.dll stdcall delayload';

这篇关于Inno安装程序无法导入DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆