如何在系统路径外使用dll [英] How to use a dll outside of the system path
问题描述
我制作了一个使用openssl dll( libeay32.dll
和 ssleay32.dll
)的应用程序。
它是indy使用它们,我不直接调用dll。
I made an application that uses the openssl dlls (libeay32.dll
and ssleay32.dll
).
It is indy using them, I don't call the dlls directly.
我发现避免安装程序的最简单的解决方法(我只是delpoy一个exe和我可以这样做)是:
The simplest workaround i found to avoid an installer (i just delpoy an exe and i am ok with this approach) is to:
- 将dll作为exe的资源
- 在程序开始时,我将其提取到exe文件夹中
- exe使用它们
是完美的,但我想通过在临时文件夹中提取dll而不是exe文件夹(在许多情况下是桌面)来改进方法。
This is perfect but I would like to improve the approach by extracting the dlls in a temp folder and not on the exe folder (that in many cases is the desktop).
问题是我不知道如何强制应用程序在temp文件夹中使用dll,因为现在的行为是:
如果dll不在当前目录下,尝试在系统路径中定义的目录中进行搜索谁知道一个解决方案,迫使indy在我的临时路径中使用dll?
The problem is that I don't know how to force the application to use the dlls in the temp folder, because now the behaviour is: if dlls are not in current directory try to search in the directories defined in the system path.
(如暂时注册dll)
Who knows a solution to force indy to use the dlls in my temp path? (like "temporarly registering the dlls")
推荐答案
使用 LoadLibrary
,一旦你有将它们写入临时文件夹。
这将使Indy的 LoadLibrary
在需要时使用您的DLL:
Load the DLLs yourself with LoadLibrary
as soon as you have written them to the temp folder.
This will make Indy's LoadLibrary
use your DLLs when they need them:
如果lpFileName不包含路径,并且有多个
加载的模块具有相同的基本名称和扩展名,函数
将返回一个句柄最初加载的模块。
If lpFileName does not include a path and there is more than one loaded module with the same base name and extension, the function returns a handle to the module that was loaded first.
这篇关于如何在系统路径外使用dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!