鼠标挂钩回调没叫?

时间:2014-01-31 19:26:28

标签: winapi mouse-hook

我正试图像这样挂钩鼠标:

#include <windows.h>
#include <stdio.h>

HHOOK mouseHook;

LRESULT WINAPI MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    MessageBox(0, "Not Called :-(", "M", 0);

    return CallNextHookEx(mouseHook, nCode, wParam, lParam);
}

int main()
{
    mouseHook = SetWindowsHookEx(WH_MOUSE,
                                 (HOOKPROC)MouseHookProc,
                                 GetModuleHandle(NULL),
                                 0);

    printf("Press enter to exit.\n");
    getchar();

    return 0;
}

但消息框永远不会出现。我认为一切都很好,但似乎有些不对劲。

提前致谢。

0 个答案:

没有答案