gpt4 book ai didi

c++ - hell 图书馆(又名 DLL hell )

转载 作者:可可西里 更新时间:2023-11-01 13:50:48 25 4
gpt4 key购买 nike

在我的一个项目中,我使用了一个动态加载包装器 DLL(导出 C 风格函数)的 Delphi 应用程序,后者又静态链接到一堆第 3 方 DLL。

它在我的测试机器上工作正常,但在我的客户计算机上它无法初始化并出现错误消息,如“在 TMYlibrary.dll 中找不到入口点 _somefunction@4AKKZ”。

在对 sysinternal 的进程监视器进行一些调查后,我意识到 Windows 会首先查找 windows/sytem32 中的 DLL,因此如果 system32 中存在一个名为 my DLL 的 DLL,windows 会选择它一个并尝试在其中找到我的函数入口点 - 这会失败。

您知道可以更改 Windows 的 DLL 的搜索行为吗?


附加信息

  • [更新] .exe 文件位于应用程序文件夹树的顶层。
  • Wrapper 和第 3 方 DLL 都位于我的应用程序文件夹的子文件夹/bin 中
  • 开发平台为windows XP/7,dll使用VS2008,应用程序使用Delphi 2010

最佳答案

我自己找到了另一个解决方案:

SetDllDirectory 将额外的搜索路径添加到要查看的位置列表。

来自 http://msdn.microsoft.com/en-us/library/ms686203%28v=VS.85%29.aspx

After calling SetDllDirectory, the DLL search path is:

  1. The directory from which the application loaded.
  2. The directory specified by the lpPathName parameter.
  3. The system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is System32.
  4. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System.
  5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  6. The directories that are listed in the PATH environment variable.

(也许我应该在发布到 SO 之前进行谷歌搜索;)

关于c++ - hell 图书馆(又名 DLL hell ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3306499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com