InPowerS.Net

 找回密碼
 註冊
搜索
查看: 2234|回復: 0

鍵盤攔截 ( Ctrl+Alt+Del、Alt+Tab、Ctrl+Esc、Alt+F4、M$ 等組合Hot Key )

[複製鏈接]
發表於 2008-12-26 13:03:10 | 顯示全部樓層 |閱讀模式
本帖最後由 肥龍 於 2008-12-26 13:09 編輯

VB.Net 寫法
:

' API 宣告
Private Declare Sub keybd_event Lib "user32" _

(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)


Private Sub Form1_Load _
(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ControlTask (True)

End Sub

Private Sub Form1_Closed _
(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed

ControlTask (False)

End Sub

Private Sub ControlTask(ByVal blnFlag As Boolean)

Dim strKey As String


blnFlag = Not blnFlag


KeyPreview = True


strKey = "HKCU\software\microsoft\windows\currentversion\policies\"


With CreateObject("WScript.Shell")


.RegWrite(strKey & "system\DisableTaskMgr", blnFlag)


.RegWrite(strKey & "Explorer\NoLogoff", blnFlag)


.RegWrite(strKey & "Explorer\NoClose", blnFlag)


.RegWrite(strKey & "system\DisableLockWorkstation", blnFlag)


.RegWrite(strKey & "system\DisableChangePassword", blnFlag)


.RegWrite(strKey & "Explorer\NoViewContextMenu", blnFlag)


.RegWrite(strKey & "Explorer\NoChangeStartMenu", blnFlag)


.RegWrite(strKey & "Explorer\NoRun", blnFlag)


.RegWrite(strKey & "Explorer\NoSetTaskbar", blnFlag)


End With

End Sub

Private Sub Form1_KeyDown _
(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

Dim KeyCode As Short = e.KeyCode


Dim Shift As Short = e.KeyData \ 65536


If KeyCode = 91 Or KeyCode = 92 Then


keybd_event(20, 0, 2, 0) ' M$


keybd_event(91, 0, 2, 0) ' M$


End If


If Shift = 4 And KeyCode = 18 Then keybd_event(18, 0, 2, 0) 'Alt+Tab


If Shift = 2 And KeyCode = 17 Then keybd_event(17, 0, 2, 0) 'Ctrl+Esc


If Shift = 4 And KeyCode = 115 Then keybd_event(115, 0, 2, 0) 'Alt+F4


If KeyCode = 112 Then keybd_event(112, 0, 2, 0) 'F1


KeyCode = 0

End Sub
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

小黑屋|Archiver|手機版|InPowerS.Net

GMT+8, 2018-10-19 23:39

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表