各位大虾,我想写一个dll,里面想用mfc的CRecordSet,可是我只要一把afxdb.h包进来,编译就报如下错d:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
Error executing cl.exe.一下是stdafx.h// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//#if !defined(AFX_STDAFX_H__9E7FD2D9_F268_434C_A1B8_E27E7872C437__INCLUDED_)
#define AFX_STDAFX_H__9E7FD2D9_F268_434C_A1B8_E27E7872C437__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Insert your headers here
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers#include <windows.h>
#include <afxdb.h>
// TODO: reference additional headers your program requires here//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_STDAFX_H__9E7FD2D9_F268_434C_A1B8_E27E7872C437__INCLUDED_)
这是什么原因呀,请各位大虾帮忙解释一下,本人第一次写dll可能问题有点
浅,请各位高手指点,谢谢!!

解决方案 »

  1.   

    错误提示不是说不能包含windows.h吗,你去掉试试。
      

  2.   

    不清楚, 难道Windows.h文件没有头文件保护? 你换一下include 的顺序吧.
      

  3.   

    // stdafx.h : include file for standard system include files,
    //  or project specific include files that are used frequently, but
    //      are changed infrequently
    //#if !defined(AFX_STDAFX_H__9E7FD2D9_F268_434C_A1B8_E27E7872C437__INCLUDED_)
    #define AFX_STDAFX_H__9E7FD2D9_F268_434C_A1B8_E27E7872C437__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#include <afxdb.h>
    // Insert your headers here
    #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers#include <windows.h>// TODO: reference additional headers your program requires here//{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_STDAFX_H__9E7FD2D9_F268_434C_A1B8_E27E7872C437__INCLUDED_)