#include HWND window; int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASS wc = {0}; MSG msg; DWORD ticks, ticks2; HHOOK kbd_hook, mouse_hook; wc.lpfnWndProc = &DefWindowProc; wc.lpszClassName = "testwc"; RegisterClass(&wc); window = CreateWindow("testwc", "test", WS_OVERLAPPED | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0); ticks = GetTickCount(); for (;;) { if (PeekMessage(&msg, NULL, WM_NULL, WM_KEYFIRST, PM_REMOVE)) { if (msg.message == WM_QUIT) { DestroyWindow(window); break; } TranslateMessage(&msg); DispatchMessage(&msg); } //simulated work ticks2 = GetTickCount(); for (;;) { UINT i; volatile int dummy = 1; for (; i < 10000 && dummy; i++) ; if (GetTickCount() - ticks2 >= 10) break; } printf("main loop %u tick latency\n", GetTickCount() - ticks); ticks = GetTickCount(); } }