#include #include void DoEvilThings(void); LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: { //SetTimer (hwnd, 42, 300, NULL) ; // 300 seconds (5 mins) //ShutdownBlockReasonCreate(hwnd,"DERP DERP"); --> pointless, only need the 2 window messages. crashes xp SetProcessShutdownParameters(0x100,0); // <--- shutdown last, hopefully after the AV } break; case WM_CLOSE: { DoEvilThings(); DestroyWindow(hwnd); } break; case WM_QUERYENDSESSION: { DoEvilThings(); } break; case WM_ENDSESSION: { DoEvilThings(); } break; case WM_TIMER: { // meh... } break; case WM_DESTROY: { PostQuitMessage(0); } break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = "lol"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { return 0; } hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"lol","Just messin around",WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL); if(hwnd == NULL) { return 0; } ShowWindow(hwnd, SW_HIDE); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } void DoEvilThings(void) { MessageBox(GetDesktopWindow(),"Derp","Derp",MB_OK); }