动态链接库(Dynamic Link Library 或者 Dynamic-link Library,缩写为 DLL),是微软公司在微软Windows操作系统中,实现共享函数库概念的一种方式。
以上是百度百科对DLL的释义,对DLL的科普到此结束,下面开始利用VS2010建立应用一个简单的DLL实例
环境准备:VS2010
本篇目的:旨在弄清如何用显示和隐式方法建立一个DLL程序
进入实践工作:
第一步:首先我们建立一个DLL的工程
选择Visual C++ 新建 Win32Project
名称:SUMDLL
方案名:DLLTEST1
下面就跟着图片next
注意勾选上Export symbols,点击Finish,出现下面的东东
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jrlOCLI2-1608012734264)(https://img-blog.youkuaiyun.com/20151007160326001)]
出现了一个SUMDLL工程,不多说,把不需要的代码注释掉,SUMDLL工程的源码如下
头文件中SUMDLL.h:
// 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 SUMDLL_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
// SUMDLL_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef SUMDLL_EXPORTS
#define SUMDLL_API __declspec(dllexport)
#else
#define SUMDLL_API