DLL在Windows上搜索 [英] DLL search on windows

查看:174
本文介绍了DLL在Windows上搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在linux上,为了程序搜索库,我们有 LIBRARY_PATH LD_LIBRARY_PATH 环境变量。我们在Windows上有类似的东西吗?特别是Windows 7?

On linux, we have LIBRARY_PATH and LD_LIBRARY_PATH environment variables in order for programs to search for libraries. Do we have similar thing on windows? Particularly Windows 7?

此外,我想知道DLL使用的最佳实践(在哪里放置,使用envs或不等等),因为我想在Windows上工作每个人都做,而不是为了解决这个问题:)

Also, I would like to know best practices for DLL use (where to put them, use envs or not, etc.), since I want to work on windows like everyone does, and not to sloth myself on workarounds :)

推荐答案

本MSDN文章解释了默认的搜索顺序。我引用:

This MSDN article explains the default search order. I quote:


  1. 由lpFileName指定的目录。

  2. 系统目录。使用GetSystemDirectory函数获取此目录的路径。

  3. 16位系统目录。没有获取此目录的路径的功能,但它被搜索。

  4. Windows目录。使用GetWindowsDirectory函数获取此目录的路径。

  5. 当前目录。

  6. PATH环境变量中列出的目录。请注意,这不包括由App Paths注册表项指定的每个应用程序路径。在计算DLL搜索路径时,App Paths键不被使用。

  1. The directory specified by lpFileName.
  2. The system directory. Use the GetSystemDirectory function to get the path of this directory.
  3. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  4. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  5. The current directory.
  6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.

在(1)中,如果静态链接到DLL的存根库,我认为lpFileName指定的目录是进程的exe的路径。

In (1), if you statically linked against the DLL's stub library, I think "the directory specified by lpFileName" is the process's exe's path.

这篇关于DLL在Windows上搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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