English 中文(简体)
SetWindowsHookEx 指的调用方法
原标题:calling the method pointed to by SetWindowsHookEx
HHOOK WINAPI SetWindowsHookEx(
 __in  int idHook,
 __in  HOOKPROC lpfn,
 __in  HINSTANCE hMod,
 __in  DWORD dwThreadId
);

此处的" http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx" rel=“nofollow”>doc 表示 lpfn 是钩子程序的指针。 让钩子程序为 :

keyboardProcessing(.....) {
}

我该怎么称呼这个钩子程序?即使我称这个钩子程序为钩子程序,我该如何接收键盘?

请解释 SetWindowsHookEx 的功能是如何运行的? 它如何称呼实际程序员定义的钩子处理密钥的方法?

最佳回答

"http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx" rel=“nofollow”>SetWindowsHookEx 功能被用于登记一些 Windows事件的自定义处理器。 从 MSDN :

将一个应用程序定义的钩子程序安装到钩子链中。您将安装一个钩子程序来监视系统对某些类型的事件。这些事件或者与特定的线索相关联,或者与在同一个桌面上的线索和呼叫线索相关联。

这意味着,对于选中的钩子类型(例如键盘事件) 来说, Windows 会调用所提供的程序 ( lpfn ) 通知发生该类型事件。 例如, 您可以使用它从键盘上获取所有事件, 即使它们没有被指向您的应用程序窗口( 设想写入宏记录器) 。

我该怎么称呼这个钩子程序?

您不必调用该程序, 您会在调用 < code> SetWindowsHookEx 时提供其地址, 然后视窗会在需要时为您调用 。

即使我叫这个钩子程序 我怎样才能收到键盘?

As said you do not have to call it, if you register a hook for WH_KEYBOARD then Windows will call that procedure for each keyboard event. Do not forget to call CallNextHookEx inside your procedure, hook is a chain of procedures and each one is responsible to call the next procedure in the chain. Finally release the hook before you quit your application with UnhookWindowsHookEx.

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签