//--------------------------------------------------------------------------- #include #include "D:\\Borland\\CBuilder5\\Include\\winable.h" #pragma hdrstop LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM); char szClassName[ ] = "BabyBlock"; UINT blockmsg; WNDCLASSEX wincl = {0}; MSG messages; HWND hwnd, prevwnd; #pragma argsused int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { blockmsg = RegisterWindowMessage("BlockThatBaby"); prevwnd = FindWindow(szClassName, szClassName); if(prevwnd) { PostMessage(prevwnd, blockmsg, 0, 0); exit(0); } wincl.hInstance = hInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; wincl.cbSize = sizeof(WNDCLASSEX); if(!RegisterClassEx(&wincl)) return 0; hwnd = CreateWindowEx(WS_EX_TOOLWINDOW, szClassName, szClassName, 0, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, hInstance, 0); if(!hwnd) return(0); while(GetMessage(&messages, 0, 0, 0)) DispatchMessage(&messages); return messages.wParam; } /***********************************************************/ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HANDLE hprocess; if(message == blockmsg) { Sleep(2000); BlockInput(TRUE); } switch(message) { case WM_CREATE: hprocess = GetCurrentProcess(); PostMessage(hwnd, blockmsg, 0, 0); SetPriorityClass(hprocess, IDLE_PRIORITY_CLASS); SetProcessWorkingSetSize(hprocess, -1, -1); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }