编写MFC拓展DLL

工程名为 mfcExDLL,创建MFC拓展DLL工程后,自动生成以下源文件:
mfcExDLL.cpp ,mfcExDLL.def ,mfcExDLL.rc ,StdAfx.cpp
以下头文件:
Resource.h ,StdAfx.h


添加 mfcExDLL.h 头文件用于自定义函数的声明

mfcExDLL.h

#ifndef mfcExDLL
#define mfcExDLL

#progma once

#ifdef DLL_API
#else
#define DLL_API extern "C" __declspec(dllimport)
#endif


DLL_API int __stdcall MyFunction();


#endif
mfcExDLL.cpp

//...
#define DLL_API extern "C" __declspec(dllexport)
#include"mfcExDLL.h"

int __stdcall MyFunction()
{
	//...
}

mfcExDLL.def

//...
MyFunction

若要在其他语言中使用这个DLL,在编写DLL是不要用MFC的数据类型如CString

猜你喜欢

转载自blog.csdn.net/qq_24282081/article/details/80562952
今日推荐