延迟加载 DLL
我迫切需要帮助,我需要在 Visual Studio 中管理应用程序依赖项。应用程序仅在特定版本的 Windows(例如 Windows 7)上链接到 DLL,而在其他环境中,不应加载 DLL。我如何才能使用 DLL 延迟加载来实现这一目标,因为这个主题对我来说是全新的,并且网上没有关于这个特定问题的任何好的参考资料。
问候
I am in desperate need of help, I need to manage an application dependency in Visual Studio. The application links to a DLL only on a specific version of windows, lets say Windows 7. and on other environments, the DLL should not be loaded. How will I be able to achieve that using DLL Delay Loading as this topic is completely new to me and there isn't any good references online for this particular matter.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的项目可以通过在“链接器/输入/延迟加载的 DLL”字段中指定它来指定它所依赖的 dll 在需要时加载。对于不同的构建配置,此设置可能有所不同。
Your project can specify that a dll it depends upon should but be loaded when needed, by specifying it in the Linker/Input/Delay Loaded DLLs field. This setting can be different for different build configurations.
MSDN 此处有一个很好的描述。
基本上,您所做的是将有问题的 DLL 设置在延迟加载部分。然后,在您调用该 DLL 中的函数之前,它不会加载该 DLL。
从上面的链接:
MSDN has a pretty good description here.
Basically what you are doing is setting the DLL in question to be in the delay load section. It will then not load that DLL until you make a call to a function that is in that DLL.
From the above link:
您是否考虑过使用动态 使用
LoadLibrary< 加载
/code> 和
GetProcAddress
?这可能更容易使用。Instead of using delay loading, have you considered using dynamic loading with
LoadLibrary
andGetProcAddress
? This is likely to be simpler to use.