Post a hook mouse roller scrolling DLL. (I am disabled, everyone bricks, thank you for cooperation !!) / / ================================ ==== Library hookprj; Uses sysutils, classes, unit1 in 'unit1.pas'; exportsenablemsghook, // Just output these two functions, disableMsghook; // beginend. //======= ======================================================================================================================================================================================================== ===================1 Unit1;
Interface
Useswindows, Messages;
VarhookHandle: hHOOK; // Hook of the handle value. Function MsghookProc (Code: "WPARAM: longint; msg: longint): LRESULT; stdcall; // Mouse hook callback function, that is, use it to process what you want to do after you get the message. . // ncode parameter is the hook flag, generally only cares about less than 0. // WPARAM parameter indicates that the type of mouse message is // LParam parameter is a pointer to the TMouseHookStruct structure. The structure contains the state of the mouse message, I only use the HWND one / / ie the window handle to pass to the mouse message. // Return Value If you are not 0, Windows is lost, and other programs will not receive this message.
function EnableMsgHook: Boolean; stdcall; export; function DisableMsgHook: Boolean; stdcall; export; // Boolean functions are two types, success is returned Trueimplementationfunction MsgHookProc (Code: Integer; WParam: Longint; Msg: Longint): LRESULT; STDCall; begin if (code = hc_action) THEN IF PMSG (MSG) ^. Message = WM_Mousewheel dam // mouse scroll Begin IF HiWord (PMSG (MSG) ^. wparam) = 120 Then // Rolling begin // Do you want you to think made. ShowWindow (PMSG (MSG) ^. Hwnd, sw_maximize; end; if Hiword (PMSG (MSG) ^. Wparam) <> 120 kiln //, becom // do what you want to do. SHOWWINDOW (PMSG (MSG) ^. Hwnd, sw_restore; end; pmsg (msg) ^. Message: = 0; end; result: = CallNexthookex (HookHandle, Cord, WPARAM, Longint); End; Function EnableMsghook : Boolean; stdcall; export; beginif hookhandle = 0 THEN / / For security, it must be judged to set the hook again. The third parameter of the third parameter is defined in Delphi, and it is possible. The fourth parameter must be 0HOOKHANDLE: = SETWINDOWSHOKEX (Wh_getMessage, @ msghookProc, hinstance, 0); result: = true; endelseresult: = false;
Function disablemsghook: boolean; stdcall; export; beginif hookhandle <> 0 dam// If you have a hook, you will remove him. BeginunhookWindowsHooKex (HookHandle); hookhandle: = 0; Result: = true; endelseresult: = false;
End.
/ / ==================================== The interface function is EnableMsGHOOK and DISABLEMSGHOOK. How to use, everyone should be clear, I am comparative dish for Delphi, I hope everyone pointed out that it is correct! ! ! What is the problem, you can go to my blog message! http://blog.9cbs.net/biku