延迟加载 DLL 和关联的 .lib 文件

发布于 2024-09-27 15:54:06 字数 440 浏览 19 评论 0原文

我试图在我的应用程序中延迟加载 wintrust.dll 和 crypt32.dll (这些用于在 DLL 中执行数字签名/发布者检查)。我用的是VS2008。将这两个 DLL 添加为项目属性链接器部分的延迟加载属性中的条目后,我仍然收到 LNK4199 警告,表示未从 DLL 中加载任何内容,并且 LNK2019 错误无法解析 WinVerifyTrust 等符号。

将以下内容添加为“附加依赖项”可以缓解此问题:crypt32.lib 和 wintrust.lib。我现在没有遇到链接问题。但是,我想知道如何确保它没有链接到静态库?由于潜在的许可问题,我不想链接到静态库。我想动态加载 Windows 中安装的 DLL,并希望 DelayLoad 可以帮助我做到这一点,而不必求助于 LoadLibrary 和 GetProcAddress 函数调用。

任何有关所有不同库使用/链接选项的信息将不胜感激!

谢谢。

I am attempting to delay load wintrust.dll and crypt32.dll in my application (these are used to perform digital signature/publisher checks in a DLL). I am using VS2008. After adding these two DLLs as entries in the Delay Load property in the Linker section of my project properties, I still get LNK4199 warnings that nothing was loaded from the DLL and LNK2019 errors unable to resolve symbols such as WinVerifyTrust.

Adding the following as entries to Additional Dependencies alleviates this problem: crypt32.lib and wintrust.lib. I now get no issues with linking. However, what I am wondering is how do I make sure this isn't being linked to the static lib? I do not want to link to the static lib because of potential licensing issues. I want to dynamically load the DLLs that are installed in Windows, and was hoping DelayLoad could help me do this without having to resort to LoadLibrary and GetProcAddress function calls.

Any information about all the different library usage/linking options would be greatly appreciated!

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情徒 2024-10-04 15:54:06

延迟加载并不能让您免于链接到 lib 文件。通常,DLL 在应用程序启动后立即加载。延迟加载只是将其延迟到您第一次从该 DLL 调用函数为止。无论哪种方式,您都需要链接到 lib 文件,以便链接器可以验证您正在调用的函数是否确实存在于 DLL 中。

如果您不想链接到 lib 文件,唯一的出路是使用 LoadLibraryGetProcAddress

Delay loading doesn't free you from having to link to the lib file. Normally, DLLs are loaded as soon as your application starts. Delay loading just delays this until the first time you call a function from that DLL. Either way, you need to link to the lib file so that the linker can verify that the functions you are calling are actually present in the DLL.

If you don't want to link to the lib files, your only way out is to use LoadLibrary and GetProcAddress.

眼泪淡了忧伤 2024-10-04 15:54:06

这些没有静态的 .lib。 SDK 库始终是导入库,而不是静态 .lib,因为相应的 Windows API 位于 DLL 中。无需担心这一点。

There is no static .lib for these. The SDK libraries are always import libraries, not static .libs because the corresponding Windows API lives in a DLL. No need to worry about this.

尛丟丟 2024-10-04 15:54:06

DependecyWalker 是一种可以帮助您确定事物是否按预期链接的工具: http://www.dependencywalker.com/ - 具体来说,在延迟加载的情况下,它会用特殊符号对其进行标记。

One tool that can help you determine if things are being linked as you expect is DependecyWalker: http://www.dependencywalker.com/ - specifically, in the case of delay-loads it marks them with a special symbol.

素衣风尘叹 2024-10-04 15:54:06

您可能需要查看 Win32 API 方法 LoadLibrary 和 GetProcAddress

You may want to look at the Win32 API methods LoadLibrary and GetProcAddress.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文