如何在系统路径之外使用dll [英] How to use a dll outside of the system path

查看:20
本文介绍了如何在系统路径之外使用dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个使用 openssl dll(libeay32.dllssleay32.dll)的应用程序.使用它们是独立的,我不直接调用 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.

我发现避免安装程序的最简单解决方法(我只是删除了一个 exe,我对这种方法没问题)是:

The simplest workaround i found to avoid an installer (i just delpoy an exe and i am ok with this approach) is to:

  1. 将dll作为exe的资源
  2. 在程序启动时,我将它们解压缩到 exe 文件夹中
  3. exe 使用它们

这很完美,但我想通过在临时文件夹而不是 exe 文件夹(在许多情况下是桌面)中提取 dll 来改进方法.

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).

问题是我不知道如何强制应用程序使用临时文件夹中的 dll,因为现在的行为是:如果 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.

谁知道强制 indy 在我的临时路径中使用 dll 的解决方案?(例如临时注册 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屋!

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