#include "afxwin.h"
class CMinApp: public CWinApp;
{public: virtual BOOL InitInstance();};
BOOL CMinApp::InitInstance()
{
CFrameWnd* pFrame=new CFrameWnd;
pFrame->Create(0,_T("A Minimal MFC Program"));
pFrame->ShowWindow(SW_SHOWMAXIMIZED);
pFrame->UpdateWindow();
AfxGetApp()->m_pMainWnd=pFrame;
return TRUE;
}
CMinApp MyApp;
上面这个程序为什么运行编译时,VC++总说fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>,到底哪里有问题呀?请大家帮帮我这个小菜吧!!

解决方案 »

  1.   

    如果你已经include了stdafx.h,就把上面的#include "afxwin.h"去掉。
      

  2.   

    头文件重复包含,把#include "afxwin.h"替换为#include "stdafx.h"
      

  3.   

    不好意思,我是照一本书练习的,这个程序的完整部分应是这样的:
    // lx3.cpp : Defines the entry point for the application.
    //#include "stdafx.h"int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
      // TODO: Place code here.
    #include "afxwin.h"
    class CMinApp: public CWinApp;
    {public: virtual BOOL InitInstance();};
    BOOL CMinApp::InitInstance()
    {
    CFrameWnd* pFrame=new CFrameWnd;
    pFrame->Create(0,_T("A Minimal MFC Program"));
    pFrame->ShowWindow(SW_SHOWMAXIMIZED);
    pFrame->UpdateWindow();
    AfxGetApp()->m_pMainWnd=pFrame;
    return TRUE;
    }
    CMinApp MyApp;
    return 0;
    }
    在Project的Setting...中,设定使用MFC.
      

  4.   

    你看的是什么书?扔了算了,很不规范呀。
    #include "afxwin.h"
    一般都是放到stdafx.h里面的。
    使用mfc的时候#include是要有顺序的
      

  5.   

    你写的什么程序哦?
    windows程序哪有这么简单
      

  6.   

    这个错误是文件中如
    #ifndef XXXX
    #err  err dicription
    的预编译语句产生的,你有一个头文件不能要或是需要修改