控制台应用程序中添加对MFC的支持

在windows控制台应用程序中,肯能会想使用一些MFC中的类,如CStringArray等,通过下面两步简单的设置可以添加对MFC的支持:

1、右击工程名 -> References 选择 All Configuration

 ->Configuration Properties ->General->Use of MFC ->Use MFC in a Shared DLL

2、在stdafx.h头文件中添加一下内容:

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
#endif
#include <afx.h>
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>                     // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

 

原文地址:https://www.cnblogs.com/cmranger/p/4077626.html