gpt4 book ai didi

c++ - 如何将dll包含为相对路径?

转载 作者:行者123 更新时间:2023-11-30 01:46:04 30 4
gpt4 key购买 nike

我的项目中有一个 dll,我通过绝对路径 (C:\test\something\abc.dll) 将其加载到我的项目中。如何相对加载它或者是否有更好的方法将它包含在 visual studio 项目中?

最佳答案

MSDN::

Before the system searches for a DLL, it checks the following:

  • If a DLL with the same module name is already loaded in memory, the systemuses the loaded DLL, no matter which directory it is in. The systemdoes not search for the DLL.

  • If the DLL is on the list of known DLLsfor the version of Windows on which the application is running, thesystem uses its copy of the known DLL (and the known DLL's dependentDLLs, if any). The system does not search for the DLL. For a list ofknown DLLs on the current system, see the following registry key:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\KnownDLLs.

Dll 的标准搜索顺序是::

  1. The directory from which the application loaded.
  2. The current directory.
  3. The system directory.
  4. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  5. The Windows directory.
  6. The directories that are listed in the PATH environment variable.

您始终可以将您的 Dll 与应用程序放在同一目录中。不建议将其作为应用程序中的资源携带。

关于c++ - 如何将dll包含为相对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33685962/

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