HOOk快捷键
#include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include "消息钩子dll.h" #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code)&0x8000)?1:0) BOOL g_bHide = TRUE; HHOOK g_Hook = 0; LRESULT CALLBACK KeyboardProc( int code, // 消息类型 WPARAM wParam, // 虚拟码 LPARAM lParam) { // 按键信息 // 判断是否wParam与lParam都有键盘消息,是的话则执行打印操作 if (code == HC_ACTION) { HWND hFindWin = FindWindow(NULL, L"windows程序分析工具"); if (KEYDOWN(VK_MENU) && KEYDOWN(0x41)) { ShowWindow(hFindWin, g_bHide?SW_HIDE : SW_SHOW); g_bHide = !g_bHide; } } return CallNextHookEx(g_Hook, code, wParam, lParam); } extern "C" _declspec(dllexport) BOOL InstallHook() { if (g_Hook == 0) { g_Hook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, GetModuleHandleA("01 消息钩子dll.dll"), 0); return TRUE; } return FALSE; } extern "C" _declspec(dllexport) BOOL UnstallHook() { if (g_Hook != 0) { UnhookWindowsHookEx(g_Hook); g_Hook = 0; return TRUE; } return FALSE; }
让数据变得更安全!