win32程序增加mfc支持

首先,在 stdafx.h中,屏蔽掉 #include<windows.h>

然后在 stdafx.h中加入

#ifndef VC_EXTRALEAN 
#define VC_EXTRALEAN        // 从 Windows 头中排除极少使用的资料 #endif  
#include <afx.h> 
#include <afxwin.h>         // MFC 核心组件和标准组件 #include <afxext.h>         // MFC 扩展  
#endif

如果编译出现

error LNK2005: _DllMain@12 已经在 dllmain.obj 中定义

那么就在dllmain.cpp中加入

// The following symbol used to force inclusion of this module for _USRDLL
#ifdef _X86_
extern "C" { int _afxForceUSRDLL; }
#else
extern "C" { int __afxForceUSRDLL; }
#endif

用来强制执行用户自己定义的main函数

猜你喜欢

转载自blog.csdn.net/Lasuerte/article/details/83578410