Пример простейшей программы для Windows


#include < windows.h >
LRESULT CALLBACK HelloWorldWndProc ( HWND, UINT, UINT, LONG );
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow )
{
HWND hWnd ;
WNDCLASS WndClass ;
MSG Msg;
char szClassName[] = "HelloWorld";
/* Регистрируем создаваемый класс */
/* Заполняем структуру типа WNDCLASS */
WndClass.style = CS_HREDRAW | CS_VREDRAW;
WndClass.lpfnWndProc = HelloWorldWndProc;
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.lpszMenuName = NULL;
WndClass.lpszClassName = szClassName;
if(!RegisterClass(&WndClass))
{
MessageBox(NULL,"Cannot register class","Error",MB_OK);
return 0;
}
hWnd = CreateWindow(szClassName, "Program No 1",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
if(!hWnd)
{
MessageBox(NULL,"Cannot create window","Error",MB_OK);
return 0;
}
/* Show our window */
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
/* Beginning of messages cycle */
while(GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK HelloWorldWndProc (HWND hWnd, UINT Message,
UINT wParam, LONG lParam)
{
HDC hDC;
PAINTSTRUCT PaintStruct;
RECT Rect;
switch(Message)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &PaintStruct);
GetClientRect(hWnd,&Rect);
DrawText (hDC,"Hello, World!", -1, &Rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hWnd,&PaintStruct);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,Message,wParam, lParam);
}

Текст программы взят из источника:
Румянцев П.В. Азбука программирования в Win32 API. – М.: Горячая линия – Телеком, 2004. – 312 с.