1、创建Windows窗口
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW|CS_NOCLOSE;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = “test”;
wcex.hIconSm = NULL;RegisterClassEx(&wcex);
hWnd = ::CreateWindowEx();
2、注册键盘钩子
// 键盘事件回调函数
LRESULT CALLBACK KeyboardHookCallback(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode >= 0) {
// 提取键盘事件信息
KBDLLHOOKSTR