钩子dllvar hHook: Integer; ProcSaveExit: Pointer;function HookProc(Code: Integer; wParam: wParam; lParam: lParam): LRESULT; stdcall;begin if Code >= 0 then if wParam = WM_CREATE then if 不是我要的窗口,由lparam取得窗口信息判断 then begin Result := 100; SendMessage(对方句柄, WM_CREATE, 0, 0); PostMessage(对方句柄, WM_CLOST, 0, 0); Exit; end; Result := CallNextHookEx(hHook, Code, wParam, lParam);end;function SetHook: Boolean; stdcall; export;begin hHook := SetwindowsHookEx(WH_CALLWNDPROC, HookProc, HInstance, 0);//或者用WH_GETMESSAGE钩子 Result := hHook <> 0;end;procedure UnHook; stdcall; export;begin if hHook <> 0 then UnHookWindowsHookEx(hHook);end;procedure KeyHookExit; far;begin if hHook <> 0 then UnHook; ExitProc := ProcSaveExit;end;exports SetHook, UnHook;begin ProcSaveExit := ExitProc; ExitProc := @KeyHookExit;end.