#include <windows.h>
#include <stdio.h>LRESULT CALLBACK WinSunProc(HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam
);int WINAPI WinMain(
HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)
{
WNDCLASS winclass;
winclass.cbClsExtra=0;
winclass.cbClsExtra=0;
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.hCursor=LoadCursor(NULL,IDC_CROSS);
winclass.hIcon=LoadIcon(NULL,IDI_ERROR);
winclass.hInstance=hInstance;
winclass.lpfnWndProc=WinSunProc;
winclass.lpszClassName="TestApiApp";
winclass.lpszMenuName=NULL;
winclass.style=CS_HREDRAW | CS_VREDRAW;
if(!RegisterClass(&winclass))
{
char szChar[20];
sprintf(szChar,"errorcode is %d",GetLastError);
MessageBox(NULL,szChar,"提示",0);
return false;
}; HWND hwnd;
hwnd=CreateWindow("TestApiApp","测试程序",WS_OVERLAPPEDWINDOW,0,0,400,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd); MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return 0;
}LRESULT CALLBACK WinSunProc(HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"Char is %d",wParam);
MessageBox(hwnd,szChar,"提示",0);
break;
case WM_LBUTTONDOWN:
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"测试",strlen("测试"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}