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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/154281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:21:28  来源:igfitidea点击:

Windows path searching in LoadLibrary with manifest

windowsdllmanifestloadlibraryside-by-side

提问by chrisd

If you call LoadLibrarywithout a path (e.g., LoadLibrary("whatever.dll"), Windows will generally follow its standard search algorithm, the same one it uses to find EXEs.

如果您在LoadLibrary没有路径的情况下调用(例如,LoadLibrary("whatever.dll")Windows 通常会遵循其标准搜索算法,这与它用于查找 EXE 的算法相同。

My question is this: suppose that an application manifest specifies specifies a particular version of a system DLL, say, comctl32.dll 6.0. In that case, will LoadLibrary("comctl32.dll")go immediately to the correct side-by-side folder, or does it still perform some kind of search?

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

回答by Grey Panther

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

应用程序可以通过指定完整路径、使用 DLL 重定向或使用清单来控制加载 DLL 的位置。如果没有使用这些方法,系统将在加载时搜索 DLL,如本主题所述。

So yes, if a manifest is present, it will directly go to the SxS folder.

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

回答by mox

To probe the loader when having troubles with missing libraries, you can use the "sxstrace" feature. www.codeproject.com/KB/DLL/QueryAssemblyIdentities.aspxgives some details about the dependencies between manifest and WinSxs.

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