首页 > 编程语言 > 详细

VS2015-Win32-DLL工程使用MFC

时间:2019-12-31 19:35:56      阅读:154      评论:0      收藏:0      [点我收藏+]

项目原理使用Win32的DLL工程,不能动,需要重新创建一个,所以记录下怎么在Win32的DLL工程中,使用代码添加MFC支持

 

1. 修改stdafx.h 代码

 1 #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS    // 某些 CString 构造函数将为显式的
 2 
 3 #include <afxwin.h>         // MFC 核心组件和标准组件
 4 #include <afxext.h>         // MFC 扩展
 5 
 6 #ifndef _AFX_NO_OLE_SUPPORT
 7 #include <afxole.h>         // MFC OLE 类
 8 #include <afxodlgs.h>       // MFC OLE 对话框类
 9 #include <afxdisp.h>        // MFC 自动化类
10 #endif // _AFX_NO_OLE_SUPPORT
11 
12 #ifndef _AFX_NO_DB_SUPPORT
13 #include <afxdb.h>            // MFC ODBC 数据库类
14 #endif // _AFX_NO_DB_SUPPORT
15 
16 #ifndef _AFX_NO_DAO_SUPPORT
17 #include <afxdao.h>            // MFC DAO 数据库类
18 #endif // _AFX_NO_DAO_SUPPORT
19 
20 #include <afxdtctl.h>        // MFC 对 Internet Explorer 4 公共控件的支持
21 #ifndef _AFX_NO_AFXCMN_SUPPORT
22 #include <afxcmn.h>            // MFC 对 Windows 公共控件的支持
23 #endif // _AFX_NO_AFXCMN_SUPPORT

 

2.  工程代码中添加

1 #ifdef _X86_
2 extern "C" { int _afxForceUSRDLL; }
3 #else
4 extern "C" { int __afxForceUSRDLL; }
5 #endif 

3. 修改工程属性

 工程-属性-常规-MFC使用,选择“在静态库中使用MFC

 工程-属性-C/C++-代码生成-运行库-  选择MT或者MTD (根据release或者debug确定)

 工程-属性-链接器-输入-忽略特定默认库-    afxcwd.lib libcmtd.lib msvcrtd.lib

 

最后可以编译使用MFC了

VS2015-Win32-DLL工程使用MFC

原文:https://www.cnblogs.com/nightnine/p/12126465.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!