VB6。0怎么同时禁用ctrl+alt+delete.alt+tab.和win键和ctrl+esc组合键

我想做个桌面锁定的小工具,在VB6。0中怎么同时禁用ctrl+alt+delete.alt+tab.和win键和ctrl+esc组合键新手希望给个详细点的代码,,,,,可... 我想做个桌面锁定的小工具,在VB6。0中怎么同时禁用ctrl+alt+delete.alt+tab.和win键和ctrl+esc组合键
新手 希望给个详细点的代码,,,,,可以加分,,,
展开
 我来答
屈涵O6
2009-07-21 · TA获得超过140个赞
知道小有建树答主
回答量:97
采纳率:0%
帮助的人:109万
展开全部
○ 窗体代码
Private Sub Form_Load()
' 安装钩子
lHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf CallKeyHookProc, App.hInstance, 0)
End Sub

Private Sub Form_Unload(Cancel As Integer)
' 卸载钩子
UnhookWindowsHookEx lHook
End Sub

○ 新建一个模块
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

Public lHook As Long

Dim p As KBDLLHOOKSTRUCT

'键盘钩子
Public Function CallKeyHookProc(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(Alt+F4)、Esc+Ctrl、左右 Win 和徽标键
End If
End If

If fEatKeystroke Then
' 设置为 1 可以屏蔽按键
CallKeyHookProc = 1
Else
CallKeyHookProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
End If
End Function

参考资料: 照别人改的

闲话看人生
2009-07-20 · 超过34用户采纳过TA的回答
知道答主
回答量:149
采纳率:100%
帮助的人:39.7万
展开全部
先声明函数
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Const SPI_SCREENSAVERRUNNING = 97

然后可以用按钮来实现该功能
Private Sub Command1_Click()
Dim r As Integer
Dim p As Boolean
If Command1.Caption = "屏蔽" Then
r = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, p, 0)
Command1.Caption = "有效"
Else
r = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, p, 0)
Command1.Caption = "屏蔽"
End If
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友d427d827b
2009-07-20 · TA获得超过324个赞
知道小有建树答主
回答量:292
采纳率:0%
帮助的人:268万
展开全部
非常抱歉,这些组合键在系统中优先级最高,是无法屏蔽的。
如果非要防止任务管理器,可以以一定的频率检查窗口,并实时关掉任务管理器
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式