DLL是组成windows系统的基石,在很多情况下的编程是离不开它的,今天说一下关于DLL编程的一些基础,也是必须要了解的。
主要分为两大类:(1)DLL的编写 (2)DLL的使用
1.DLL的编写
DLL编写需要一个头文件和一个源文件,头文件用于声明,源文件用于实现:
下面是我编写的一个例子程序的头文件中的内容:
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the TESTDLL_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// TESTDLL_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef TESTDLL_EXPORTS
#define TESTDLL_API __declspec

这篇博客介绍了DLL编程的基础知识,包括DLL的编写和使用。在DLL编写中,涉及头文件和源文件的创建,以及如何导出函数,主要使用`extern "C" _declspec(dllexport)`。在DLL使用部分,讲解了隐式调用和显式调用两种方法,前者通过lib文件导入,后者利用LoadLibrary API进行动态加载。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



