Winapi: setwindowshookex-set hook/unhookwindowshookex-Remove hook

Source: Internet
Author: User

Tip: If you want to set a system-level Hook, the hook function must be in the DLL.

Setwindowshookex (idhook: integer; {hook type} lpfn: tfnhookproc; {function pointer} hmod: hinst; {module (exe, DLL) handle containing hook functions; generally hinstance; for the current thread, it can be 0} dwthreadid: DWORD {associated thread; Use getcurrentthreadid to obtain the current thread; 0 to indicate system-level hook}): hhook; {return hook handle; 0 indicates failure} // hook type idhook option: wh_msgfilter =-1; {Thread level; intercept message between user and control} wh_journalrecord = 0; {system level; record all input messages sent from the message queue in the message queue, which occurs when the message is cleared from the queue; can be used for macro record} wh_journalplayback = 1; {system level; playback of messages recorded by wh_journalrecord, that is, these messages are re-sent to the Message Queue} wh_keyboard = 2; {system level or line level; the Keyboard Message is intercepted} wh_getmessage = 3; {system level or line level; intercepted messages sent from the Message Queue} wh_callwndproc = 4; {system level or line level; intercepted messages sent to the target window, occurred when sendmessage was called} wh_cbt = 5; {system level or line level; basic system messages are intercepted, such as window creation, activation, closing, maximum minimization, and moving.} wh_sysmsgfilter = 6; {system level; intercept messages between users and controls in the system} wh_mouse = 7; {system level or line level; intercept mouse messages} wh_hardware = 8; {system level or line level; intercepted messages from non-standard hardware (non-mouse or keyboard)} wh_debug = 9; {system level or line level; called before calling other hooks for debugging hooks} wh_shell = 10; {system-level or thread-level; intercepted messages sent to the shell application} wh_foregroundidle = 11; {system-level or thread-level; called when the program's front-end thread is idle} wh_callwndprocret = 12; {system-level or thread-level; intercepted messages processed in the target window. After sendmessage is called,} response unhookwindowshookex (HHK: hhook {hook handle}): bool; {true/false}

--------------------------------------------------------------------------------
From http://www.cnblogs.com/del/archive/2008/02/25/1080541.html
Http://www.cnblogs.com/del/archive/2008/02/25/1080516.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.