#include <windows.h>
#include <winuser.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 ;
        
    WNDCLASwndclass ;
           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) ;
        
}--------------------Configuration: hellowin - Win32 Debug--------------------
Compiling...
hellowin.c
d:\c\hellowin\hellowin\hellowin.c(19) : error C2065: 'WNDCLASwndclass' : undeclared identifier
d:\c\hellowin\hellowin\hellowin.c(22) : error C2065: 'wndclass' : undeclared identifier
d:\c\hellowin\hellowin\hellowin.c(22) : error C2224: left of '.style' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(24) : error C2224: left of '.lpfnWndProc' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(26) : error C2224: left of '.cbClsExtra' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(28) : error C2224: left of '.cbWndExtra' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(30) : error C2224: left of '.hInstance' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(32) : error C2224: left of '.hIcon' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(34) : error C2224: left of '.hCursor' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(36) : error C2224: left of '.hbrBackground' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(38) : error C2224: left of '.lpszMenuNam' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(40) : error C2224: left of '.lpszClassName' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(43) : warning C4133: 'function' : incompatible types - from 'int *' to 'const struct tagWNDCLASSA *'
Error executing cl.exe.hellowin.obj - 12 error(s), 1 warning(s)

解决方案 »

  1.   

    因为你少打一个空格
    WNDCLASS wndclass;
      

  2.   

    连接的时候又出错了.怎么回事啊?--------------------Configuration: hellowin - Win32 Debug--------------------
    Linking...
    hellowin.obj : error LNK2001: unresolved external symbol __imp__DispatchMessageA@4
    hellowin.obj : error LNK2001: unresolved external symbol __imp__TranslateMessage@4
    hellowin.obj : error LNK2001: unresolved external symbol __imp__GetMessageA@16
    hellowin.obj : error LNK2001: unresolved external symbol __imp__UpdateWindow@4
    hellowin.obj : error LNK2001: unresolved external symbol __imp__ShowWindow@8
    hellowin.obj : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
    hellowin.obj : error LNK2001: unresolved external symbol __imp__MessageBoxA@16
    hellowin.obj : error LNK2001: unresolved external symbol __imp__RegisterClassA@4
    hellowin.obj : error LNK2001: unresolved external symbol __imp__GetStockObject@4
    hellowin.obj : error LNK2001: unresolved external symbol __imp__LoadCursorA@8
    hellowin.obj : error LNK2001: unresolved external symbol __imp__LoadIconA@8
    hellowin.obj : error LNK2001: unresolved external symbol __imp__DefWindowProcA@16
    hellowin.obj : error LNK2001: unresolved external symbol __imp__PostQuitMessage@4
    hellowin.obj : error LNK2001: unresolved external symbol __imp__EndPaint@8
    hellowin.obj : error LNK2001: unresolved external symbol __imp__DrawTextA@20
    hellowin.obj : error LNK2001: unresolved external symbol __imp__GetClientRect@8
    hellowin.obj : error LNK2001: unresolved external symbol __imp__BeginPaint@8
    Debug/hellowin.exe : fatal error LNK1120: 17 unresolved externals
    Error executing link.exe.hellowin.exe - 18 error(s), 0 warning(s)
      

  3.   

    哈哈
    d:\c\hellowin\hellowin\hellowin.c(19)   :   error   C2065:   'WNDCLASwndclass'   :   undeclared   identifier 
    WNDCLASwndclass  这个地方电子版少了个空格 WNDCLAS wndclass
      

  4.   

    拳不离手,曲不离口!我看《Windows程序设计》时,例子都是自己打上去的,即使有光盘也没有用。
    就像有些事情一样,看上去很简单,可是做起来却不是那样!
      

  5.   

    --------------------Configuration: hellowin - Win32 Debug--------------------
    Linking...
    hellowin.obj : error LNK2001: unresolved external symbol __imp__GetStockObject@4
    Debug/hellowin.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.hellowin.exe - 2 error(s), 0 warning(s)加上user32.lib了.怎么还有错误呢?
      

  6.   

    小弟佩服zaodt大哥的精神..我也要努力才行.
      

  7.   

    解决了.
    gdi.lib和wingdi.h
    多谢大家.@.@