用vb6.0怎么写一个程序可以达到禁用win7的任务管理器?(还有,怎么可以禁用某个按键?比如禁用Ctrl键)

 我来答
zx001z7d53
2012-08-05 · TA获得超过2万个赞
知道大有可为答主
回答量:2.4万
采纳率:52%
帮助的人:5644万
展开全部
'***************************
'模块代码Module1
'***************************
Option Explicit
Private Declare Function CallNextHookEx Lib "user32" _
(ByVal hHook As Long, _
ByVal nCode As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Private 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

Private Declare Function UnhookWindowsHookEx Lib "user32" _
(ByVal hHook As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)
Private Type PKBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Private Const WM_KEYDOWN = &H100
Private Const WM_SYSKEYDOWN = &H104
Private Const WM_KEYUP = &H101
Private Const WM_SYSKEYUP = &H105
Private Const VK_LWIN = &H5B
Private Const VK_RWIN = &H5C
Private Const HC_ACTION = 0
Private Const WH_KEYBOARD_LL = 13
Private Const VK_CONTROL = &H11
Private Const VK_ESCAPE = &H1B
Private Const VK_MENU = &H12
Private Const VK_TAB = &H9
Private Const VK_Delete = &H2E
Private lngHook As Long
'使用底层KeyboardHook拦截按键消息
Public Function LowLevelKeyboardProc(ByVal nCode As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Dim blnHook As Boolean
Dim p As PKBDLLHOOKSTRUCT

If nCode = HC_ACTION Then
Select Case wParam
Case WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP, WM_SYSKEYUP
Call CopyMemory(p, ByVal lParam, Len(p))
If p.vkCode = VK_LWIN Or p.vkCode = VK_RWIN Then blnHook = True '按下了左/右Win键
If p.vkCode = VK_CONTROL Or p.vkCode = VK_ESCAPE Then blnHook = True '按下了Ctrl+Esc键
If p.vkCode = VK_MENU Or p.vkCode = VK_TAB Then blnHook = True '按下了Alt+Tab键
Case Else
'do nothing
End Select
End If

If blnHook Then
LowLevelKeyboardProc = 1
Else
Call CallNextHookEx(WH_KEYBOARD_LL, nCode, wParam, lParam)
End If
End Function
Public Sub HooK()
lngHook = SetWindowsHookEx(WH_KEYBOARD_LL, _
AddressOf LowLevelKeyboardProc, _
App.hInstance, _
0)
End Sub
Public Sub UnHooK()
Call UnhookWindowsHookEx(lngHook)
End Sub

'***************************
'窗体代码Form11
'***************************
Private Sub Form_Load()
Call HooK '屏蔽Win键
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call UnHooK '取消屏蔽Win键
End Sub
信心安J
2012-08-08 · TA获得超过402个赞
知道小有建树答主
回答量:787
采纳率:0%
帮助的人:722万
展开全部
首先,win7的系统安全性要高得多,,我曾经也想用VB控制【Ctrl】+【Alt】+【Del】组合键
但是从网上找的都失败了。
其次,我的电脑系统是win7,下面“专家”的答案经本人测试无效!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式