隐式与显式链接到DLL [英] Implicit vs. Explicit linking to a DLL

查看:156
本文介绍了隐式与显式链接到DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

这是相当罕见的显式链接一个DLL。主要是因为它是痛苦和容易出错的。您需要为导出的函数编写函数指针声明,并获取LoadLibrary + GetProcAddress + FreeLibrary代码。只有当您需要对插件样式DLL的运行时依赖性或者想要从一组基于配置的DLL中进行选择时,才会这样做。或者处理版本控制,这是一个API函数,仅在稍后版本的Windows上可用。显式链接是COM和.NET DLL的默认链接。



MSDN图书馆文章


When one should implicitly or explicitly link to a DLL and what are common practices or pitfalls?

解决方案

It is fairly rare to explicitly link a DLL. Mostly because it is painful and error prone. You need to write a function pointer declaration for the exported function and get the LoadLibrary + GetProcAddress + FreeLibrary code right. You'd do so only if you need a runtime dependency on a plug-in style DLL or want to select from a set of DLLs based on configuration. Or to deal with versioning, an API function that's only available on later versions of Windows for example. Explicit linking is the default for COM and .NET DLLs.

More background info in this MSDN Library article.

这篇关于隐式与显式链接到DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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