轉自: http://blog.sina.com.cn/s/blog_5f656a170101dzcn.html
1:右擊工程名 -> References
2: Configuration Properties ->Use of MFC ->Use MFC in a Shared DLL
3: 在stdafx.h的頭文件加入如下代碼:
1 #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 2 3 #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif 4 5 #include <afx.h> #include <afxwin.h> // MFC core and standard components 6 7 #include <afxext.h> // MFC extensions #ifndef _AFX_NO_OLE_SUPPORT 8 9 #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls 10 11 #endif 12 13 #ifndef _AFX_NO_AFXCMN_SUPPORT 14 15 #include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT