For more information, see <Fifth edition of Windows Programming>
The source code of the Win32 Hello World Program is as follows:
1 # include <windows. h> 2 3 lresult callback wndproc (hwnd, uint, wparam, lparam); 4 5 Int winapi winmain (hinstance, 6 hinstance hprevinstance, 7 lpstr lpcmdline, 8 int nshowcmd) 9 {10 static tchar lpszappname [] = text ("hellowin"); 11 hwnd; 12 MSG; 13 wndclass WC; 14 15 WC. style = cs_hredraw | cs_vredraw; 16 WC. lpfnwndproc = wndproc; 17 WC. cbclsextra = 0; 18 WC. cbwndextra = 0; 19 WC. hinsta NCE = hinstance; 20 WC. hicon = loadicon (null, idi_application); 21 WC. hcursor = loadcursor (null, idc_arrow); 22 WC. hbrbackground = (hbrush) getstockobject (white_brush); 23 WC. lpszmenuname = NULL; 24 WC. lpszclassname = lpszappname; 25 26 // register window class 27 if (! Registerclass (& WC) 28 {29 MessageBox (null, text ("this program requires Windows NT! "), 30 lpszappname, mb_iconerror); 31 return 0; 32} 33 34 // create the application Main Window 35 hwnd = createwindow (lpszappname, 36 text (" the hello program "), 37 ws_overlappedwindow, 38 cw_usedefault, 39 cw_usedefault, 40 cw_usedefault, 41 cw_usedefault, 42 null, 43 null, 44 hinstance, 45 null); 46 47 // display window 48 showwindow (hwnd, nshowcmd); 49 updatewindow (hwnd); 50 51 // message loop 52 while (getmessage (& MSG, null, 0, 0) 53 {54 translatemessage (& MSG); 55 dispatchmessage (& MSG); 56} 57 58 return MSG. wparam; 59} 60 61 // 62 // window procedure function 63 // 64 lresult callback wndproc (hwnd, uint message, wparam, lparam) 65 {66 HDC; 67 paintstruct pS; 68 rect; 69 70 switch (Message) 71 {72 case wm_create: 73 return 0; 74 case wm_paint: 75 HDC = beginpaint (hwnd, & PS ); 76 getclientrect (hwnd, & rect); 77 drawtext (HDC, text ("Hello world! "),-1, & rect, 78 dt_singleline | dt_center | dt_vcenter); 79 endpaint (hwnd, & PS); 80 return 0; 81 Case wm_destroy: 82 postquitmessage (0 ); 83 return 0; 84} 85 86 return defwindowproc (hwnd, message, wparam, lparam); 87}