VS2010和VS2008 KB2465361之后,MFC静态链接 EXE体积变大问题
2011-05-07 19:03
525 查看
原文链接:http://tedwvc.wordpress.com/2011/04/16/static-mfc-code-bloat-problem-from-vc2010-is-now-in-vc2008-sp1security-fix/
大意是:
在KB2465361之后。themehelper.cpp 中调用了afxglobals.cpp中的 AfxLoadSystemLibraryUsingFullPath函数。造成afxglobals.obj 的引入。从而产生代码至少增加1.2M。
解决方法
1.卸载KB2465361,这个方法太弱智了。不小心也许又打上了。
2.在你自己的工程的stdafx.cpp中增加以下代码
其实这段代码与afxglobals.cpp中的代码一样。目的只是避免引入afxglobals.obj。
这样,你的程序体积又恢复正常了。减肥成功。。。恭喜恭喜。
推荐下面的方法
1、stdafx.h中注释掉
//#include <afxcontrolbars.h> // 功能区和控件条的 MFC 支持
2、app中将从CWinAppEx派生改成从CWinApp派生(直接在 stdafx.h 里
#define CWinAppEx CWinApp)
3、副作用:会导致一些头文件需要自己加
打了VS2008 SP1补丁会将CWinApp升级为CWinAppEx..这也是增肥的原因之一
大意是:
在KB2465361之后。themehelper.cpp 中调用了afxglobals.cpp中的 AfxLoadSystemLibraryUsingFullPath函数。造成afxglobals.obj 的引入。从而产生代码至少增加1.2M。
解决方法
1.卸载KB2465361,这个方法太弱智了。不小心也许又打上了。
2.在你自己的工程的stdafx.cpp中增加以下代码
]// this is our own local copy of the AfxLoadSystemLibraryUsingFullPath function HMODULE AfxLoadSystemLibraryUsingFullPath(const WCHAR *pszLibrary) { WCHAR wszLoadPath[MAX_PATH+1]; if (::GetSystemDirectoryW(wszLoadPath, _countof(wszLoadPath)) == 0) { return NULL; } if (wszLoadPath[wcslen(wszLoadPath)-1] != L'//') { if (wcscat_s(wszLoadPath, _countof(wszLoadPath), L"//") != 0) { return NULL; } } if (wcscat_s(wszLoadPath, _countof(wszLoadPath), pszLibrary) != 0) { return NULL; } return(::AfxCtxLoadLibraryW(wszLoadPath)); }
其实这段代码与afxglobals.cpp中的代码一样。目的只是避免引入afxglobals.obj。
这样,你的程序体积又恢复正常了。减肥成功。。。恭喜恭喜。
推荐下面的方法
1、stdafx.h中注释掉
//#include <afxcontrolbars.h> // 功能区和控件条的 MFC 支持
2、app中将从CWinAppEx派生改成从CWinApp派生(直接在 stdafx.h 里
#define CWinAppEx CWinApp)
3、副作用:会导致一些头文件需要自己加
打了VS2008 SP1补丁会将CWinApp升级为CWinAppEx..这也是增肥的原因之一
相关文章推荐
- 转:VS2010和VS2008 KB2465361之后,MFC静态链接 EXE体积变大问题
- Vs2008 执行Mfc工程出现cmd.exe错误问题
- VS2010无法调试问题解决 最近,因为公司开发的需要,对开发环境进行全面的升级,在这其中也遇到了不少问题,在之后将陆续整理出来,以便以后查看。 之前开发环境:VS2008,ArcGIS9.3,Ar
- VS2010 MFC做了一个简单的串口通信上位机,那么问题来了:生成的exe不能再同学的电脑上运行
- 关于安装IE8之后VS2008使用MFC出现问题的解决方法
- 关于安装IE8之后VS2008使用MFC出现问题的解决方法
- 在win7下用vs2008 编译程序时出现“mt.exe停止工作”问题的解决办法
- 给 VS2008 / VS2010 MFC 项目添加启动画面
- vs2010静态链接MFC库报链接错误
- 对于vs2008下MFC的编译或者说vc6到vs2008的移植性问题
- VS2008编译的MFC兼容性问题
- 关于vs2008 和 vs2010 工程常在断点调试的时候卡死(卸了输入法即解决了问题)
- MFC中引入POCO库之后找不到API的问题
- 关于WebValidates.dll验证控件在VS2008和VS2010中使用的问题
- Vs2010与Vs2008安装在同一台电脑上问题
- VS2008 MFC对话框工程中,在对话框中添加ActiveX控件生成类的问题
- labview生成exe之后的路径问题
- 给 VS2008 / VS2010 MFC 项目添加启动画面
- VS2008下使用MFC,做托盘以及气泡提示,shellapi.h的问题。。
- VS2008编译的MFC兼容性问题