Я знакомлюсь с использованием Hooks в Win32 C ++ (в частности, с KeyboardHooks), и у меня есть проблема и вопрос.
Во-первых, я пытаюсь просто создать / объявить объект HHook, но когда яdo Microsoft Visual C ++ выдает ошибку компилятора:
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
Это строка кода, которая генерирует эту ошибку:
HHook keyboardHook;
Какую библиотеку Windows мне нужно включить, чтобы использоватьКласс Hook?Я сделал
#include <windows.h>
Мой другой вопрос: для использования этих хуков мне нужен UAC?
РЕДАКТИРОВАТЬ: С большим кодом:
// 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);