1.新建工程test中选择”MFC [dll]”dll类型选择第二项"Regular DLL With MFC shared linked",完成
2.在test.h中添加
extern “C” 返回类型 _declspec(dllexport)函数名(参数列表);
3.在test.cpp中最后写
extern “C” 返回类型 _declspec(dllexport)函数名(参数列表) {函数体}
4.编译、连接Debug文件夹下生成dll文件
二、动态链接库使用
1.将dll拷到工程目录
2.在合适的地方使用
HINSTANCE hdll = LoadLibrary(“文件名.dll”); if(hdll) { typedef 返回类型(*p)(参数类型); p myFunction = (p)GetProcAddress(hdll, ”函数名”); (*myFunction)(参数列表);//使用dll中的函数 } FreeLibrary(hdll);