Win2K/NT/XP环境下LWIN,RWIN,WIN+Any,Ctrl+Esc,Alt+Esc,Alt+TAB等键的禁用

原创 2004年08月26日 00:48:00

参考国外一些网站,论坛代码,得到以下综合,以上环境中测试通过,版权归原作者所有。
add a checkbox named chkDisable.caption="&Disable ALT-TAB, ALT-ESC, CTRL-ESC,LWin,RWin,Win+Any"
to a new from named frmMain.frm in new project hook_kb_LL.vbp
add code below:

Option Explicit

Dim hhkLowLevelKybd As Long

Private Sub chkDisable_Click()
If chkDisable = vbChecked Then
      hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
Else
       UnhookWindowsHookEx hhkLowLevelKybd
        hhkLowLevelKybd = 0
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
If hhkLowLevelKybd <> 0 Then UnhookWindowsHookEx hhkLowLevelKybd
End Sub

in new module named modDisableLowLevelKeys.bas
code below:
Option Explicit

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Const HC_ACTION = 0
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105
Public Const VK_TAB = &H9
Public Const VK_CONTROL = &H11
Public Const VK_ESCAPE = &H1B

Public Const WH_KEYBOARD_LL = 13
Public Const LLKHF_ALTDOWN = &H20

Public Type KBDLLHOOKSTRUCT
       vkCode As Long
       scanCode As Long
       flags As Long
       time As Long
      dwExtraInfo As Long
End Type

Dim p As KBDLLHOOKSTRUCT

Public Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
   Dim fEatKeystroke As Boolean
  
   If (nCode = HC_ACTION) Then
      If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Or wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Then
         CopyMemory p, ByVal lParam, Len(p)
         fEatKeystroke = _
           ((p.vkCode = VK_TAB) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
           ((p.vkCode = VK_ESCAPE) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
           ((p.flags And LLKHF_ALTDOWN) <> 0) Or _
           ((p.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _
           ((p.vkCode = 91) Or (p.vkCode = 92) Or (p.vkCode = 93))
           'TAB+ALT
           'Esc+ALT
           'Alt+Any(Alt+F4)
           'Esc+Ctrl
           '左右Win 和徽标键
            End If
    End If
   
    If fEatKeystroke Then
        LowLevelKeyboardProc = -1
    Else
        LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
    End If
End Function

补充参考更多:

http://www.vbnet.mvps.org/index.html?code/hooks/lowlevelkeyboardproc.htm
http://www.zjol.com.cn/vbbible/software/program/vb/ccw/main.htm#Hook

Win7 禁止Ctrl+Alt+Del、Win+L等任意系统热键

标 题: 【原创】Win7 修改Winlogon.exe进程一个字节禁止Ctrl+Alt+Del、Win+L等任意系统热键 作 者: heiheiabcd 时 间: 2012-12-01,10...
  • linfei2707
  • linfei2707
  • 2014年05月07日 18:13
  • 7867

MFC中如何拦截Alt+?、Ctrl+?、Ctrl+Alt+?、Ctrl+Shift+?、Ctrl+Shift+Alt+?、Shift+?系列的组合键,以及拦截Alt+F4,回车和Esc键

程序的下载地址为:http://download.csdn.net/detail/xing_yufei/5056315   看过好多别人写的程序,有支持热键呼叫的,并且热键可以在程序中自定义设定。...
  • xing_yufei
  • xing_yufei
  • 2013年02月06日 14:17
  • 2123

钩子编程(HOOK) 屏蔽所有按键、鼠标及系统功能键 (4)

[钩子编程(HOOK) 屏蔽所有按键鼠标及系统功能键]上篇文章《钩子编程(HOOK) 安装系统全局钩子》已经详细的讲解了全局钩子的安装,下面我们增强一下钩子的功能,实现屏蔽所有按键鼠标与系统功能键。要...
  • u012339743
  • u012339743
  • 2014年05月15日 13:32
  • 4192

Windows XP系统中如何屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键序列

Windows XP系统中如何屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键序列 编译/northtibet 关键字:Ctrl+Alt+Del,Alt+Tab,Ctr...
  • wangjieest
  • wangjieest
  • 2012年02月07日 15:39
  • 1910

Windows XP系统中如何屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键序列

 Windows XP系统中如何屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键序列编译/northtibet关键字:Ctrl+Alt+Del,Alt+Tab,Ctrl+Esc,V...
  • CButtonST
  • CButtonST
  • 2011年06月21日 15:37
  • 747

Windows XP系统中如何屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键

  • 2006年02月23日 09:05
  • 93KB
  • 下载

Windows XP系统中屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键序列

  • 2009年01月21日 10:12
  • 319KB
  • 下载

Windows XP系统中如何屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键序列

Windows XP系统中如何屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键序列 编译/northtibet 关键字:Ctrl+Alt+Del,Alt+Tab,Ctr...
  • liang888113
  • liang888113
  • 2011年10月13日 13:48
  • 782

如何启用和禁用用于登录到Windows XP, Vista和Win7的CTRL+ALT+DELETE序列

    根据每个用户不同的需要,我们可能需要启用或禁用”CTRL+ALT+DELETE”序列,欢迎大家使用我们制作的Fix it小工具来帮助大家实现:启用”CTRL+ALT+DELETE”序列禁用”C...
  • Microsoft_FixIt
  • Microsoft_FixIt
  • 2011年03月23日 13:28
  • 1443

屏蔽系统按键Alt-TAB, Ctl-Esc, Alt-Esc Win键Start M

  • 2004年06月28日 00:00
  • 24KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Win2K/NT/XP环境下LWIN,RWIN,WIN+Any,Ctrl+Esc,Alt+Esc,Alt+TAB等键的禁用
举报原因:
原因补充:

(最多只允许输入30个字)