使用清单在LoadLibrary中搜索Windows路径

时间:2020-03-06 14:56:18  来源:igfitidea点击:

如果我们不带路径调用" LoadLibrary"(例如," LoadLibrary(" whatever.dll")"),则Windows通常会遵循其标准搜索算法,即用于查找EXE的相同算法。

我的问题是:假设应用程序清单指定指定了系统DLL的特定版本,例如comctl32.dll 6.0。在这种情况下,LoadLibrary(" comctl32.dll")会立即转到正确的并排文件夹,还是仍然执行某种搜索?

解决方案

从Microsoft:

Applications can control the location from which a DLL is loaded by specifying a full path, using DLL redirection, or by using a manifest. If none of these methods are used, the system searches for the DLL at load time as described in this topic.

是的,如果存在清单,它将直接转到SxS文件夹。

要在缺少库时遇到问题时检测加载程序,可以使用" sxstrace"功能。 www.codeproject.com/KB/DLL/QueryAssemblyIdentities.aspx提供了有关清单和WinSxs之间的依赖关系的一些详细信息。