Sign in to follow this  
gretty

Using Win32 Keyboard Hooks

Recommended Posts

gretty    273
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:
[quote] [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

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

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

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
ApochPiQ    23064
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this