Using Win32 Keyboard Hooks

Started by
1 comment, last by ApochPiQ 12 years, 10 months ago
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?
Advertisement
have you looked at the MSDN "Using Hooks" example ?

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

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.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement