#include<windows.h>
LRESULT CALLBACK WndProc (HWMD,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,hPrevInstance,
   PSTR szCmdLine,int iCmdShow)//error C2146: syntax error : missing ')' before identifier 'szCm
                                                                //error C2081: 'hPrevInstance' : name in formal parameter list il
                                                                 //error C2081: 'PSTR' : name in formal parameter list illegal
                                                                 //error C2061: syntax error : identifier 'szCmdLine'
                                                                 //error C2059: syntax error : ';'
                                                                 //error C2059: syntax error : ','/
                                                                 //error C2059: syntax error : ')'

                                                                 
{
static TCHAR szAppName[]=TEXT("hELLOwIN");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style= CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
    wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon (NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackgrond=(HBRUSH)GETsTOCKoBJECT(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if(!RegisterClass(&wndclass))
{
Message(NULL,TEXT("This program reqires Windows NT!"),
szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName,
TExt("The Hello Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
    {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}LRESULT CALLBACK WndProc (HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch (message)
{
case WM_CREATE:
   PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
       return 0;
   case MWM_PAINT:
//error C2051: case expression not constant
// error C2065: 'MWM_PAINT' : undeclared identifier
[b]
   hdc=BeginPaint(hwnd,&ps);
   GetClientRect(hwdn,&rect);
                                 //   error C2065: 'hwdn' : undeclared identifier
                                   //warning C4047: 'function' : 'struct HWND__ *' differs in levels of indirection from 'int '
                                 //warning C4024: 'GetClientRect' : different types for formal and actual parameter 1
   DrawText(hdc,TEXT("Hello,Windows 98!"),-1,&rect,
   DT_SINGLELINE|DT_CENTER|DT_VCENTER);
   EndPaint(hwnd,&ps);
   return 0;
   case MWM_DESTROY:
                          //error C2051: case expression not constant
                         //error C2065: 'MWM_DESTROY' : undeclared identifier

   PostQuitMessage(0);
   return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
               
}

解决方案 »

  1.   

    #include <afx.h>
      

  2.   

    #include <afx.h> ,测试一下。
      

  3.   

    #include <afx.h> ,测试一下。 秘密
      

  4.   

    是HWND,而不是HWMDHINSTANCE,hPrevInstance  这里中间多了个逗号
      

  5.   

    是wndclass.hbrBackground而不是 wndclass.hbrBackgrond是GetStockObject而不是GETsTOCKoBJECT是TEXT而不是TExt小问题太多,只找到这
      

  6.   

    对于有问题的语句加了/**/注释然后另起一行写了修正后的语句#include<windows.h>/*LRESULT CALLBACK WndProc (HWMD,UINT,WPARAM,LPARAM);*/
    LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);/*int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,hPrevInstance,*/
    int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
       PSTR szCmdLine,int iCmdShow)//error C2146: syntax error : missing ')' before identifier 'szCm
                                                                    //error C2081: 'hPrevInstance' : name in formal parameter list il
                                                                     //error C2081: 'PSTR' : name in formal parameter list illegal
                                                                     //error C2061: syntax error : identifier 'szCmdLine'
                                                                     //error C2059: syntax error : ';'
                                                                     //error C2059: syntax error : ','/
                                                                     //error C2059: syntax error : ')'
                                                                     
    {
    static TCHAR szAppName[]=TEXT("hELLOwIN");

    HWND hwnd;
    MSG msg;
    WNDCLASS wndclass;

    wndclass.style= CS_HREDRAW|CS_VREDRAW;
    wndclass.lpfnWndProc=WndProc;
        wndclass.cbClsExtra=0;
    wndclass.cbWndExtra=0;
    wndclass.hInstance=hInstance;
    wndclass.hIcon=LoadIcon (NULL,IDI_APPLICATION);
    wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
    /*wndclass.hbrBackgrond=(HBRUSH)GETsTOCKoBJECT(WHITE_BRUSH);*/
    wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName=NULL;
    wndclass.lpszClassName=szAppName; if(!RegisterClass(&wndclass))
    {
    /*Message(NULL,TEXT("This program reqires Windows NT!"),*/
    MessageBox(NULL,TEXT("This program reqires Windows NT!"),
    szAppName,MB_ICONERROR);
    return 0;
    } hwnd=CreateWindow(szAppName,
    /*TExt("The Hello Program"),*/
    TEXT("The Hello Program"),
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    NULL,
    NULL,
    hInstance,
    NULL);
    ShowWindow(hwnd,iCmdShow);
    UpdateWindow(hwnd); while(GetMessage(&msg,NULL,0,0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    } return msg.wParam;
    }LRESULT CALLBACK WndProc (HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
    {
    HDC hdc;
    PAINTSTRUCT ps;
    RECT rect;
    switch (message)
    {
    case WM_CREATE:
     PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
    return 0; /*case MWM_PAINT:*/
    case WM_PAINT:
    //error C2051: case expression not constant
    // error C2065: 'MWM_PAINT' : undeclared identifier[b]
    hdc=BeginPaint(hwnd,&ps);
    /*GetClientRect(hwdn,&rect);*/
    GetClientRect(hwnd,&rect);
                                     //   error C2065: 'hwdn' : undeclared identifier
                                       //warning C4047: 'function' : 'struct HWND__ *' differs in levels of indirection from 'int '
                                     //warning C4024: 'GetClientRect' : different types for formal and actual parameter 1 DrawText(hdc,TEXT("Hello,Windows 98!"),-1,&rect,
    DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    EndPaint(hwnd,&ps);
    return 0; /*case MWM_DESTROY:*/
    case WM_DESTROY:
                              //error C2051: case expression not constant
                             //error C2065: 'MWM_DESTROY' : undeclared identifier
    PostQuitMessage(0);
    return 0;
    }
    return DefWindowProc(hwnd,message,wParam,lParam);           
    }