程序如下(PROGRAMMING WINDOWS书里的)
#include <windows.h>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
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.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
   wndclass.lpszMenuNam = NULL ;//大家请注意这行
wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass))
     {
MessageBox ( NULL, TEXT ("This program requires Windows NT!"), 
           szAppName, MB_ICONERROR) ;
return 0 ;
     }
hwnd = CreateWindow( szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
    NULL,         // window menu handle
    hInstance,     // program instance handle
    NULL) ;      // creation parameters
     
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_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
          
GetClientRect (hwnd, &rect) ;
          
DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
   EndPaint (hwnd, &ps) ;
return 0 ;
          
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
     }
   return DefWindowProc (hwnd, message, wParam, lParam) ;
}
用DEV-C++将上面标注“大家请注意这行”的这行去掉后能编译链接,而VC6.0下提示c:\program files\microsoft visual studio\vc98\include\winnt.h(1092) : error C2146: syntax error : missing ';' before identifier 'KSPIN_LOCK'
c:\program files\microsoft visual studio\vc98\include\winnt.h(1092) : fatal error C1004: unexpected end of file found
Error executing cl.exe.dfghdfgh.exe - 2 error(s), 0 warning(s)
谢谢,问题解决马上结贴

解决方案 »

  1.   

    wndclass.lpszMenuNam少了个"e", wndclass.lpszMenuName
      

  2.   

    对了,谢谢,现在DEV-C++下能通过了,但VC还是不行,是不是VC有什么不对的设置,我是默认的
      

  3.   

    lpszMenuNam 是 lpszMenuName.我编译了能通过的
      

  4.   

    就像这样
    Pro1.cpp
    c:\program files\microsoft visual studio\vc98\include\winnt.h(1092) : error C2146: syntax error : missing ';' before identifier 'KSPIN_LOCK'
    c:\program files\microsoft visual studio\vc98\include\winnt.h(1092) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.Pro1.exe - 2 error(s), 0 warning(s)
      

  5.   

    可能你是用的Console模式编译检查一下Project->Settings->C++->Project Option
    把下面的Console改为WINDOWS/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_Console" /D "_MBCS" /Fp"Debug/as.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
      

  6.   

    程序本身没有错误!
    wndclass.lpszMenuNam = NULL ;//大家请注意这行
    这行程序里就是后面的名字写错了,改称下面就可以了:
    wndclass.lpszMenuName = NULL ;//
    但是编译环境一定要设置对,我使用的是Windows 2000 sp3,VC6.0的编译环境,具体到工程里的环境设置,我建议你直接在向导里生成一个空的Win32工程,然后把这个文件加入,编译就可以了
    我已经编译通过了
      

  7.   

    我编译器上是这样的:
    /nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Debug/te.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c 
    已经是WINDOWS了啊
      

  8.   

    TO:lianhuiyong(阳关故人) 
    我是用你说的方法做的,就是出现那样的提示,现在打SP,再试试
      

  9.   

    可能你是用的Console模式编译
    你重建一个win32 application看看。程序应该没有问题。
      

  10.   

    我也在想啊,程序好像没问题,看来是对VC太陌生了,或是网上下的那个VC不行
      

  11.   

    这段代码怎么像看过?
     是不是MFC深入浅出里面的?至少是类似的了