#include <windows.h>//编写windows程序必须包含的头文件
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);//声明窗口函数WndProc的原型
int WINAPI WinMain(HINSTANCE hINstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nShowCmd)//程序入口函数WinMain
{
    HWND hwnd;//定义窗口句柄
    MSG msg;//定义一个存储消息的变量
    char lpszClassName[]="窗口";
    WNDCLASS wc;//定义一个窗口类变量
    wc.style=0;
    wc.lpfnWndProc=WndProc;//wc.lpfnWndProc是窗口类的一个指针,它指向窗口函数WndProc
    wc.cbWndExtra=0;//分配在窗口实例后的字节数count of byte...
    wc.hInstance=hInstance;
    wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.lpszClassName=lpszClassName;
    RegisterClass(&wc);//注册窗口类
    hwnd=CreateWindow(       //创建窗口
                       lpszClassName,  //窗口类名  
                       "Windows",//窗口实例的标题
                       WS_OVERLAPPEDWINDOW,//WS_OVERLAPPEDWINDOW是一个窗口风格的实际值
                       120,50,800,600,//依次是窗口左上角的坐标值x,y,窗口的宽度,高度(它们都是int类型的)
                       NULL,//父窗口的句柄
                       NULL,//主菜单的句柄
                       hInstance,//应用程序实例句柄
                       NULL);
    ShowWindow(hwnd,nCmdShow);//显示窗口
    UpdateWindow(hwnd);
    while(GetMessage(&msg,null,0,0))//消息循环
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.lParam;
}
//-----------------------------------------------------------------------------------------------------------
//处理消息的窗口函数
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
    switch(message)
    {
        case WM_LBUTTONDOWN;
        {
            MessageBeep(0);
        }
        break;
        case WM_DESTROY;
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hwnd,message,wParam,lparam);
    }
    return 0;
}
//-------------------------------
运行结果:
Configuration: aaa - Win32 Debug--------------------
Compiling...
asd.cpp
c:\documents and settings\new\桌面\aaa\asd.cpp(12) : error C2065: 'hInstance' : undeclared identifier
c:\documents and settings\new\桌面\aaa\asd.cpp(12) : error C2440: '=' : cannot convert from 'int' to 'struct HINSTANCE__ *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\new\桌面\aaa\asd.cpp(26) : error C2065: 'nCmdShow' : undeclared identifier
c:\documents and settings\new\桌面\aaa\asd.cpp(28) : error C2065: 'null' : undeclared identifier
c:\documents and settings\new\桌面\aaa\asd.cpp(28) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.

aaa.exe - 1 error(s), 0 warning(s)

小弟刚学习MFC这个东西,这是我照着书上写的.不知道是什么原因,编译不能通过,请高手指教!谢谢!一个半天了,还是没有解决!