user593747
user593747

Reputation: 1514

Compiler error when creating a KeyBoard Hook

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:

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

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?

EDIT: With more code:

// TestHHook.cpp : Defines the entry point for the application.
//

     #include <windows.h>
#include "stdafx.h"
#include "TestHHook.h"

static HHook keyboardHook;
#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;                                // current instance
TCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name

// Forward declarations of functions included in this code module:
ATOM                MyRegisterClass(HINSTANCE hInstance);
BOOL                InitInstance(HINSTANCE, int);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);

Upvotes: 0

Views: 267

Answers (1)

Hans Passant
Hans Passant

Reputation: 941317

You are using a case sensitive language. It is HHOOK, not HHook.

Upvotes: 3

Related Questions