## Hello World in Win32 API

    //
    // HELLO.C
    //
    #include <windows.h>

    #define MESG1 "Hello World! About 70 lines of code for Hello World!"
    #define MESG2 "Written using the Windows API."

    LRESULT WINAPI MainWndProc
      ( HWND, UINT, WPARAM, LPARAM );

    int WINAPI WinMain
      ( HINSTANCE hInstance,
        HINSTANCE hPrevInstance,
        LPSTR lpszCmdLine,
        int nCmdShow
      )
    {  WNDCLASS wc;
       MSG msg;
       HWND hWnd;

       wc.lpszClassName = "HelloClass";
       wc.lpfnWndProc = MainWndProc;
       wc.style = CS_VREDRAW | CS_HREDRAW;
       wc.hInstance = hInstance;
       wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
       wc.hCursor = LoadCursor( NULL, IDC_ARROW );
       wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
       wc.lpszMenuName = NULL;
       wc.cbClsExtra = 0;
       wc.cbWndExtra = 0;
       RegisterClass( &wc );

       hWnd = CreateWindow
        ( "HelloClass",
          "Hello World",
          WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
          0,
          0,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          NULL,
          NULL,
          hInstance,
          NULL
       );

       ShowWindow( hWnd, nCmdShow );

       while( GetMessage( &msg, NULL, 0, 0 ) )
        { TranslateMessage( &msg );
          DispatchMessage( &msg );
        }
       return msg.wParam;
    }

    LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
    {  PAINTSTRUCT ps;
       HDC hDC;

       switch( msg )
        { case WM_PAINT:
           hDC = BeginPaint( hWnd, &ps );
           TextOut( hDC, 10, 10, MESG1, strlen(MESG1) );
           TextOut( hDC, 10, 25, MESG2, strlen(MESG2) );
           EndPaint( hWnd, &ps );
           break;

          case WM_DESTROY:
           PostQuitMessage( 0 );
           break;

          default:
           return( DefWindowProc( hWnd, msg, wParam, lParam ));
     }
     return 0;
    }