[WinAPI]钩住Ctrl + Alt +键盘上的Delete [英] [WinAPI] Hook Ctrl + Alt + Delete on keyboard

查看:77
本文介绍了[WinAPI]钩住Ctrl + Alt +键盘上的Delete的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我使用带有WH_KEYBOARD_LL的SetWindowHookEx来钩住键盘上的键.我尝试用以下方法钩住Ctrl + Alt + Delete:

Hi all,

I''m using SetWindowHookEx with WH_KEYBOARD_LL to hook keys on keyboard. I try to hook Ctrl + Alt + Delete with:

if (GetAsyncKeyState(VK_CONTROL) && (GetAsyncKeyState(VK_MENU) && (p->vkCode == VK_DELETE))



但这不起作用!

那么,如何使用Hook捕获事件Ctrl + Alt + Delete?

谢谢



But it doesn''t work!

So, how to catch event Ctrl+Alt+Delete with Hook?

Thank you

推荐答案

据我所知,您不能这样做.

无论如何,在用户模式下,这是不可能的.操作系统会以特殊方式处理此键盘组合.当您按Delete键并按Ctrl和Alt键时,键盘事件根本不会分派到任何应用程序.我认为截取只能在内核级别进行,如果可能的话.

OS的这种设计功能是可以解释的.例如,渴望Ctrl + Alt + Delete的映像可能会被某些挂起或以其他方式失效的应用程序捕获,从而有效地阻止了对Task Manager的访问,切换用户等.这太不安全了,不允许发生.

—SA
To best of my knowledge, you cannot do it.

This is not possible, anyway, not on the user mode. This keyboard combination is treated in a special way by the OS. When you press Delete, and Ctrl and Alt are pressed, the keyboard event does not dispatched to any of the application programs at all. I think intercepting that could only be possible on the kernel level, if possible at all.

Such design feature of OS is quite explainable. For example, lust imaging that Ctrl+Alt+Delete can be caught by some application program which would hang or otherwise become defunct, effectively blocking access to Task Manager, switching user, etc. This would be too unsafe to allow to happen.

—SA


这篇关于[WinAPI]钩住Ctrl + Alt +键盘上的Delete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆