一百分相送。(在线等待,解决后立刻给分!)

20020501 2002-05-17 01:59:23
我在用keybd_event模拟键盘输入时,其它键盘都正常,但在模拟CTRL+ALT+DEL时却没有响应这是为什么?有什么方法可以解决吗?

下面是我的模拟过程:
keybd_event(17,MapVirtualKey(17,0),KEYEVENTF_EXTENDEDKEY,0);//CTRL按下
keybd_event(18,MapVirtualKey(18,0),KEYEVENTF_EXTENDEDKEY,0);//ALT按下
keybd_event(48,MapVirtualKey(48,0),KEYEVENTF_EXTENDEDKEY,0);//DEL按下
keybd_event(48,MapVirtualKey(48,0),KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);//DEL弹起
keybd_event(17,MapVirtualKey(17,0),KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);//CTRL弹起
keybd_event(18,MapVirtualKey(18,0),KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);//ALT弹起
...全文
39 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wabc 2002-05-17
  • 打赏
  • 举报
回复
其实,你可以先分别检测Ctrl,alt,del,因为用户是不可能同时按下这三个键的,所以分别检测他们,并记录下来,一旦连续遇到这三个键,你就可以做你自己的事件了。
countrynew 2002-05-17
  • 打赏
  • 举报
回复
再请看:




http://www.csdn.net/expert/topic/402/402564.xml?temp=.3158228
蒋晟 2002-05-17
  • 打赏
  • 举报
回复
You can switch to the Winlogon Desktop and posy a message
// Winlogon uses hotkeys to trap Ctrl-Alt-Del...
PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
and then switch back to your original desktop
蒋晟 2002-05-17
  • 打赏
  • 举报
回复
A normal keyboard hook (WH_KEYBOARD) can swallow keystrokes by returning TRUE in the hook procedure. However, this will not work for system keyboard events such as the ones you listed. For Windows NT version4.0 Service Pack 3 and later, you can install a low-level keyboard hook (WH_KEYBOARD_LL) that can detect these system keyboard events and eat all of them, except for CTRL+ALT+DEL. This exception is for security reasons.

Having said that, there are some ways to get around that exception, although Dr. GUI doesn't recommend it. In Windows NT, you can write a GINA (Graphical Identification 'N' Authentication) DLL to handle the security exception. (Do a full-text search on "GINA" in Online Help to learn all about it.) Dr. GUI's preference is to leave system keys such as CTRL+ALT+DEL alone.

In Windows 95/98 you can write a filter device driver. There is also a trick for Windows 95/98 that is described in the Microsoft Knowledge Base article Q154868, "HOWTO: Block CTRL+ALT+DEL and ALT+TAB in Windows 95/98 in VB," located at http://support.microsoft.com/support/kb/articles/q154/8/68.asp. You can make a call to SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, lpvoid, 0) in order to disable the system keyboard events, including CTRL+ALT+DEL. Calling it again with the TRUE changed to FALSE will re-enable these key sequences.

The code for setting up the hooks will look like this:

hhookMouse = SetWindowsHookEx(WH_MOUSE,
(HOOKPROC) MouseFunc, hInstance, 0);

…which will cause the following hook function to be called:

LRESULT CALLBACK MouseFunc(int nCode, WPARAM wParam, LPARAM lParam)
{
if ( nCode >= 0 )
return 1;
else
return(CallNextHookEx(hhookMouse, nCode, wParam, lParam));
}

Don't forget to unhook your hook before you exit by calling the following:

UnhookWindowsHookEx(hhookMouse);

Now for the special part of your question-screen savers. Under Windows NT, screen savers run under a different desktop, where the hooks will have no effect. Once you're in the screen saver desktop, any mouse or keyboard activity will stop the screen saver. Under Windows 95/98, the screen saver is running in the same environment as the hooks. So, once the screen saver is running, the hooks will prevent keyboard or mouse activity from stopping the screen saver. Here's the interesting part: While the hooks will prevent mouse and keyboard activity from stopping the screen saver, they will not prevent such activity from delaying the screen saver from starting. That is, the screen saver will not start as long as you are clanging on the keyboard or monkeying with your mouse, even though the hooks are eating those events. This is true for Windows NT as well. So, to answer your question, the screen saver is noninterruptible with these hooks running under Windows 95/98, as long as you've taken care of the CTRL+ALT+DEL possibility.

countrynew 2002-05-17
  • 打赏
  • 举报
回复
请看



http://www.vchelp.net/article/submit/cad_key.htm
wabc 2002-05-17
  • 打赏
  • 举报
回复
不用写钩子了,这个组合键钩子是无法截获的。
如果你的确必须截获之,那么只有写一个Gina程序了
COOKER 2002-05-17
  • 打赏
  • 举报
回复
自己写个钩子试试.
20020501 2002-05-17
  • 打赏
  • 举报
回复
要怎么解决这个问题?
sammon 2002-05-17
  • 打赏
  • 举报
回复
被windows系统截获了吧
20020501 2002-05-17
  • 打赏
  • 举报
回复
无话可说,最后一次UP。
20020501 2002-05-17
  • 打赏
  • 举报
回复
upup
20020501 2002-05-17
  • 打赏
  • 举报
回复
各路大侠快出手啊。急!
sorry2000 2002-05-17
  • 打赏
  • 举报
回复
up

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧