想用全局钩子屏蔽 QQ截屏 【失败】

可能判断组合键的方法有点问题

#define _WIN32_WINNT 0x0501 #define STRICT #define WIN32_LEAN_AND_MEAN #include <stdio.h> #include <stdlib.h> #include <windows.h> DWORD g_main_tid = 0; HHOOK g_kb_hook = 0; BOOL CALLBACK con_handler (DWORD) { PostThreadMessage (g_main_tid, WM_QUIT, 0, 0); return TRUE; }; LRESULT CALLBACK kb_proc (int code, WPARAM w, LPARAM l) { PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT)l; const char *info = NULL; if (w == WM_KEYDOWN) { info = "key dn"; } else if (w == WM_KEYUP) info = "key up"; else if (w == WM_SYSKEYDOWN) info = "sys key dn"; else if (w == WM_SYSKEYUP) info = "sys key up"; printf ("%s - vkCode [%04x], scanCode [%04x]/n", info, p->vkCode, p->scanCode); if (p->vkCode==65 && ((p->flags & LLKHF_ALTDOWN)!=0) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0)) { printf("Crtl + ALT +A /n"); return TRUE; } return CallNextHookEx (g_kb_hook, code, w, l); }; int _tmain(int argc, _TCHAR* argv[]) { g_main_tid = GetCurrentThreadId (); SetConsoleCtrlHandler (&con_handler, TRUE); g_kb_hook = SetWindowsHookEx ( WH_KEYBOARD_LL, &kb_proc, GetModuleHandle (NULL), 0); if (g_kb_hook == NULL) { fprintf (stderr, "SetWindowsHookEx failed with error %d/n", ::GetLastError ()); return 0; }; MSG msg; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); }; UnhookWindowsHookEx (g_kb_hook); return 0; }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值