vb禁用系统快键键
我用b做的登录界面,alt+f4,ctrl+alt+delete,都已经经用。可是发现只要先点alt+f6接着再点alt+f4还是可以关闭界面。有办法可以禁用alt,ctrl,shift这三个键和其它建的任意组合键吗?也就是让alt,ctrl,shift这三个键无效!!
--------------------编程问答--------------------
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Integer, ByVal aBOOL As Integer) As Integer--------------------编程问答-------------------- 谢谢,但是我是想禁用alt+f6,我的窗口是置前的,所以alt+f4,alt+tab都不起作用。但是按过alt+f6后再按alt+f4窗口就推出了。 --------------------编程问答-------------------- --------------------编程问答-------------------- up --------------------编程问答-------------------- 可以使用键盘钩子,当按键为需要过滤的时侯,不调用下一个钩子,而是直接返回。 --------------------编程问答-------------------- http://www.m5home.com/bbs/dispbbs.asp?boardid=28&Id=1040&page=2
Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Private TaskBarhWnd As Long
Private IsTaskBarEnabled As Integer
Private TaskBarMenuHwnd As Integer
'禁止或允许使用 Alt-Tab
Sub FastTaskSwitching(bEnabled As Boolean)
Dim X As Long, bDisabled As Long
bDisabled = Not bEnabled
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
'禁止使用Ctrl-Alt-Del
Public Sub DisableTaskBar()
Dim EWindow As Integer
TaskBarhWnd = FindWindow("Shell_traywnd", "")
If TaskBarhWnd <> 0 Then
EWindow = IsWindowEnabled(TaskBarhWnd)
If EWindow = 1 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 0)
End If
End If
End Sub
'允许使用Ctrl-Alt-Del
Public Sub EnableTaskBar()
If IsTaskBarEnabled = 0 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 1)
End If
End Sub
禁止 Ctrl+Alt+Del
声明(For Win95):
Const SPI_SCREENSAVERRUNNING = 97
Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
lpvParam As Any, ByVal fuWinIni As Long) As Long
使用:
'禁止
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
'开启
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
可以玩玩这个,注入Winlogon.exe实现纯代码拦截CAD三键....... --------------------编程问答-------------------- CAD三键,真简单啊(Ctrl+Alt+Delete)
我个人认为,还人是键盘钩子为好。 --------------------编程问答-------------------- 都是高手哈~
APi就行哈 --------------------编程问答--------------------
又在玩‘注入’,小心被 Kill 了~~~~ ^_^
--------------------编程问答-------------------- 谢谢 --------------------编程问答--------------------
Up --------------------编程问答--------------------
不能不说这种事情最好要低调。 --------------------编程问答-------------------- 呵呵,其实退出的只要FORM_UNLOAD事件里面加入CANCEL=1就禁用了,加一个变量,当变量为退出时,CANCEL=0就OK了嘛。不过任务管理器倒是得用HOOK。 --------------------编程问答-------------------- 其实简单地通过 SubClass 吃掉 WM_SYSCOMMAND : SC_CLOSE 消息就可以。
用任务管理器都不能关闭了。
'引用 SSubTmr6.dll [http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/SSubTimer/VB6_SSubTmr_Binary.zip]--------------------编程问答--------------------
Option Explicit
Implements ISubclass
Private Const WM_SYSCOMMAND As Long = &H112
Private Const SC_CLOSE As Long = &HF060&
Private Declare Function DefWindowProc Lib "user32.dll" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private m_CanClose As Boolean
Private Sub cmdClose_Click()
m_CanClose = True
Unload Me
End Sub
Private Sub Form_Load()
m_CanClose = False
AttachMessage Me, Me.hwnd, WM_SYSCOMMAND
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
DetachMessage Me, Me.hwnd, WM_SYSCOMMAND
End Sub
Private Property Let ISubclass_MsgResponse(ByVal RHS As SSubTimer6.EMsgResponse)
End Property
Private Property Get ISubclass_MsgResponse() As SSubTimer6.EMsgResponse
ISubclass_MsgResponse = emrConsume
End Property
Private Function ISubclass_WindowProc(ByVal hwnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If (wParam = SC_CLOSE) And (Not m_CanClose) Then
Exit Function
End If
DefWindowProc hwnd, iMsg, wParam, lParam
End Function
3年前的贴子,今年"5.12"来回!纪念汶川地震4周年!
--------------------编程问答-------------------- TNND! --------------------编程问答-------------------- 以后回帖看好时间.................................... --------------------编程问答-------------------- 列表中日期字段没有年份,故意的故意的 --------------------编程问答-------------------- 没注意是两个活塞
唉,岁月催人老啊 --------------------编程问答-------------------- 19楼作废,回错贴了 --------------------编程问答-------------------- 这也从侧面说明了VB版没啥活力了 --------------------编程问答--------------------
不用在意,楼主早已出国定居,不会回来了.不然早就结贴了!
--------------------编程问答-------------------- 难道是朝鲜?不能连internet?再或者是非洲部落没有internet? --------------------编程问答-------------------- 你们真损.....
补充:VB , 基础类