Caveats
This hook hampers system performance considerably because it intercepts many
common events that occur in the system, such as changing a
control’s focus or manipulating a window. Unlike the
WH_SHELL hook, this hook works for all windows and
not just the top-level unowned windows in the system. If you can
solve a problem with the WH_SHELL hook instead of
with the WH_CBT hook, by all means use the
WH_SHELL hook. The WH_SHELL
hook puts less of a strain on the system because not all window
events are intercepted -- just those of top-level unowned windows.
If you want to use the HCBT_KEYSKIPPED code, you
must install a WM_KEYBOARD hook. Likewise, if you
want to use the HCBT_CLICKSKIPPED code, you must
install a WM_MOUSE hook.
If you use the HCBT_KEYSKIPPED code to initiate an
action for a keystroke, you should also test for either the
WM_KEYUP or WM_KEYDOWN message
and then initiate the action for one of these messages. Otherwise,
the action will be performed twice, once for each message.
Most likely, when using the WH_CBT hook, you also
will use one or more other hooks to augment it. When doing so, verify
that you release each hook not only before the application ends, but
also before it is reinstalled. You can install the
WH_JOURNALPLAYBACK hook multiple times in a single
CBT application’s lifetime. It is imperative that you release
this hook after it is finished or it might seem as if your
application has locked up.
There is an article in the Microsoft Developer Network (MSDN) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access