• Advertisement
Sign in to follow this  

Using Win32 Keyboard Hooks

This topic is 2449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello

I am introducing myself to using Hooks in Win32 C++ (specifically KeyboardHooks) & I have an issue & a question.

First off, I am trying to just create/declare a HHook object, but when I do Microsoft Visual C++ gives a compiler error saying:
[font="Consolas"][size="1"][font="Consolas"][size="1"]c:\users\soribo\desktop\c++ programming\visual c++ programming\testhhook\testhhook\testhhook.cpp(7): error C2146: syntax error : missing ';' before identifier 'keyboardHook'

1>c:\users\soribo\desktop\c++ programming\visual c++ programming\testhhook\testhhook\testhhook.cpp(7): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>c:\users\soribo\desktop\c++ programming\visual c++ programming\testhhook\testhhook\testhhook.cpp(7): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

[/font][/font][/quote]

This is the line of code that generates this error:
HHook keyboardHook;

What windows library do I need to include to use the HHook class? I have done #include <windows.h>

My other question is, to use these hooks do I need UAC?

Share this post


Link to post
Share on other sites
Advertisement
There is no such thing as an HHook. It's an HHOOK, and you don't create them yourself; handles are "opaque" meaning that you don't know what the actual data structure looks like from your code. You retrieve a hook handle by asking for one from the Windows API.

Read the example linked by ryan20fun.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement