| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1969 人关注过本帖
标题:关于在xp下锁定系统热键
只看楼主 加入收藏
msxjc
Rank: 1
等 级:新手上路
帖 子:83
专家分:0
注 册:2005-3-28
结帖率:50%
收藏
 问题点数:0 回复次数:14 
关于在xp下锁定系统热键
请问哪位高手知道能用vb6.0锁定Windows xp的系统热键吗?如果可以,要怎么写代码啊?
搜索更多相关主题的帖子: 系统热键 Windows 代码 
2005-03-28 17:52
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 

Win2K/NT/XP环境下禁用 LWIN,RWIN,WIN+Any,Ctrl+Esc,Alt+Esc,Alt+TAB 等热键(Ctrl+Alt+Delete无法禁用) 'in a form 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 a module 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.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _ ((p.vkCode = 91) Or (p.vkCode = 92) Or (p.vkCode = 93)) '左右Win 和徽标键 End If End If If fEatKeystroke Then LowLevelKeyboardProc = -1 Else LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam) End If End Function


天津网站建设 http://www./
2005-03-29 08:36
longhao
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2004-9-10
收藏
得分:0 
能说说为什么那些常量非得设成那样不可吗?有些看不懂呢,常常看这些API调用,经常都看到设很多的常量,却都看不懂呢~~

携手共进,陪伴彼此~
2005-03-29 15:36
msxjc
Rank: 1
等 级:新手上路
帖 子:83
专家分:0
注 册:2005-3-28
收藏
得分:0 
那ALT+F4能锁定吗?还有如何才能禁用任务管理器啊?(好像个性注册表就行了,不过我不知道怎么改?还望赐教。

2005-03-29 17:53
我爱论坛
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2004-12-3
收藏
得分:0 

用户可以使用“任务管理器”对话框来启动和结束本地进程,查看和管理其他计算机上的进程,改变进程的优先级。通过修改注册表,可以禁止用户使用“任务管理器”。新建一个双字节(REG_DWORD)值项HKEY_CURRENT_USERSoftwareMicrosoft WindowsCurrentVersionPoliciesSystemDisableTaskMgr,修改其值为1

2005-03-29 21:35
msxjc
Rank: 1
等 级:新手上路
帖 子:83
专家分:0
注 册:2005-3-28
收藏
得分:0 
请教griefforyou,你提供的代码是可以锁定系统的热键,不过没有锁定ALT+F4,请问这个热键可以锁定吗?请赐教代码。无限感激

2005-03-29 22:11
我爱论坛
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2004-12-3
收藏
得分:0 
Ctrl+Alt+Delete能禁用,不过得用第三方控件。
2005-03-29 22:41
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 
Alt+F4不是系统热键,而是每个应用的关闭快捷键。 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.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _ ((p.vkCode = 91) Or (p.vkCode = 92) Or (p.vkCode = 93)) Or _ ((p.vkCode = vbKeyF4) And (p.flags And LLKHF_ALTDOWN) <> 0) '加入这行代码屏弊Alt+F4 End If End If If fEatKeystroke Then LowLevelKeyboardProc = -1 Else LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam) End If End Function

[此贴子已经被作者于2005-4-7 22:12:17编辑过]


天津网站建设 http://www./
2005-03-29 22:44
msxjc
Rank: 1
等 级:新手上路
帖 子:83
专家分:0
注 册:2005-3-28
收藏
得分:0 
请教我爱论坛:能禁用Ctrl+Alt+Delete的第三方控件你有吗?没有的话,在哪儿可以下载啊?

2005-03-29 22:53
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 

天津网站建设 http://www./
2005-03-29 23:40
快速回复:关于在xp下锁定系统热键
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024960 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved