vs控制台应用程序如果想用MFC的类型,需要包含的头文件

vs2010下,新建一个vc的控制台应用程序,如果在程序中使用到了MFC的类型,比如DWORD,BOOL,LPCTSTR,可以添加<afxwin.h>头文件,而afxwin.h 开始就是 #include <afx.h>。
解释:<afx.h>一些定义与设置,为MFC提供最基本支持,将各种松散的东西组织起来,同时为MFC 类库的后续建立 提供方便。一个最简单的 MFC 只需 afxwin.h 即可,而afxwin.h 开始就是 #include <afx.h>

1.vc控制台应用程序,加了<afxwin.h>头文件后报错:

错误    1    error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]    d:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afx.h    24

2.需要右键项目,"属性"->"配置属性"->"常规",改为"在共享DLL中使用MFC",编译即可。
 

#include <afx.h>
#include <afxwin.h>         // MFC 核心组件和标准组件
#include <afxext.h>         // MFC 扩展
#include <afxdisp.h>        // MFC 自动化类
发布了27 篇原创文章 · 获赞 9 · 访问量 4905

猜你喜欢

转载自blog.csdn.net/weixin_41761608/article/details/92649203