|
Hook Procedures
To take advantage of a particular type of hook, the developer provides a hook
procedure and uses the SetWindowsHookEx function to install it into the chain associated with the hook. A hook
procedure must have the following syntax:
LRESULT CALLBACK HookProc(
int nCode,
WPARAM wParam,
LPARAM lParam)
HookProc is a placeholder for an application-defined name.
The nCode parameter is a hook code that the hook procedure uses to determine the action
to perform. The value of the hook code depends on the type of the hook; each
type has its own characteristic set of hook codes. The values of the wParam and lParam parameters depend on the hook code, but they typically contain information
about a message that was sent or posted.
The SetWindowsHookEx function always installs a hook procedure at the beginning of a hook chain.
When an event occurs that is monitored by a particular type of hook, Windows
calls the procedure at the beginning of the hook chain associated with the hook.
Each hook procedure in the chain determines whether to pass the event to the
next procedure. A hook procedure passes an event to the next procedure by calling
the CallNextHookEx function.
Note that the hook procedures for some types of hooks can only monitor
messages. Windows passes messages to each hook procedure, regardless of whether a
particular procedure calls CallNextHookEx.
A hook procedure can be global, monitoring messages for all threads in the
system, or it can be thread specific, monitoring messages for only an individual
thread. A global hook procedure can be called in the context of any application,
so the procedure must be in a separate dynamic-link library (DLL) module. A
thread specific hook procedure is called only in the context of the associated
thread. If an application installs a hook procedure for one of its own threads,
the hook procedure can be in either the same module as the rest of the
application's code or in a DLL. If the application installs a hook procedure for a
thread of a different application, the procedure must be in a DLL. For information,
see Dynamic-Link Libraries.
Note You should use global hooks only for debugging purposes; otherwise, you
should avoid them. Global hooks hurt system performance and cause conflicts with
other applications that implement the same type of global hook.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|