Troubleshooting process protection through the WH_CBT type Hook and NINDEX for GWL_WndProc. Example Download: Accessories [SafeProcess.rar]: http://blog.blogchina.com/upload/2004-12-20/20041220143803647829.RAR 1. Find whether the Windows Task Manager window exists via Timer Process or other means. :: FindWindow (NULL, "Windows Task Manager") If existed, enter the second step. 2. Set a WH_CBT type hook g_cbthook = setWindowsHooKex (WH_CBT, (HookProc) CBTPROC, G_HINSTANCE, NULL; HCBT_ACBTIVATE and HCBT_DESTROYWND two types of messages are processed in (hookProc) CBTPROC.
// The CBT hook Proc (Computer Based Training Hook) LRESULT CALLBACK CBTProc (int nCode, WPARAM wParam, LPARAM lParam) {CHAR szText [256]; CHAR szWindowText [32]; HWND hWnd; memset (szWindowText, NULL, sizeof (szWindowText )); STRCPY (SzwindowText, "Task Manager Warning"); Switch (Ncode) {CASE HCBT_AACTIVATE: HWND = (hwnd) WParam; getWindowText (hwnd, sztext, 256); if (StrCMP (Sztext, SzwindowText) == 0 ) {if (! bSetWindowLong) {g_hWnd = Wnd; g_orgProc = (WNDPROC) SetWindowLong (hWnd, GWL_WNDPROC, (LONG) NewWndProc); bSetWindowLong = TRUE;}} break; case HCBT_DESTROYWND: hWnd = (HWND) wParam; GetWindowText (hWnd , SZText, 256); IF (STRC mp (szText, szWindowText) == 0) {SetWindowLong (g_hWnd, GWL_WNDPROC, (LONG) g_orgProc); g_hWnd = NULL; bSetWindowLong = false;} break;} return CallNextHookEx (NULL, nCode, wParam, lParam);} // End of the hook procedure 3. NewWndProc If the user clicks on the OK button, you can join your own processing, which is invalid.