Windshadow2005
March 23rd, 2005, 08:16 AM
I want to make a software for my Internet cafe which needs to disable the win key & Cltr+Esc key & also Cltr+Alt+Del key
I am trying the code to capturing the key event of the key board I mean to disable the win key & Cltrl + Esc key & also Alt+Cltrl+Del key but I am not successfull with it. There may be some error in my codeing so that I am not able to over come this problem. So please help me to rectifing my code. My code is given below, Please watch and rectifing for me so that I am able to disable the all the windows hot key such as win key & Cltrl + Esc key & also Alt+Cltrl+Del key
My Code
'In a module
Public Const WH_KEYBOARD = 2
Public Const VK_SHIFT = &H10
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
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
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public hHook As Long
Public Function KeyboardProc(ByVal idHook As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Check if key is pressed down
If wParam = WM_KEYDOWN Then
'Copy Memory of key to variable hookKey
Call CopyMemory(hookKey, ByVal lParam, Len(hookKey))
keyCode = hookKey.code
'Check array for key
For i = 0 To 21
If keyCode = keyChar(i) Then keys = keys & "[" & keyList(i) & "]"
Next
For i = 22 To 47
If keyCode = keyChar(i) Then keys = keys & keyList(i)
Next
'Letters and numbers
If (keyCode >= 48 And keyCode <= 57) Or (keyCode >= 65 And keyCode <= 90) Then
keys = keys & Chr(keyCode)
ElseIf keyCode = 13 Then
keys = keys & vbNewLine & vbTab
End If
'If the message is not one we want to trap, pass it along
KeyboardProc = CallNextHookEx(hook, ncode, wParam, lParam)
End Function
'In a form, called Form1
Private Sub Form_Load()
'set a keyboard hook
hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf KeyboardProc, App.hInstance, App.ThreadID)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'remove the windows-hook
UnhookWindowsHookEx hHook
End Sub
Please find out the solution for me ....
Thanking
I am trying the code to capturing the key event of the key board I mean to disable the win key & Cltrl + Esc key & also Alt+Cltrl+Del key but I am not successfull with it. There may be some error in my codeing so that I am not able to over come this problem. So please help me to rectifing my code. My code is given below, Please watch and rectifing for me so that I am able to disable the all the windows hot key such as win key & Cltrl + Esc key & also Alt+Cltrl+Del key
My Code
'In a module
Public Const WH_KEYBOARD = 2
Public Const VK_SHIFT = &H10
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
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
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public hHook As Long
Public Function KeyboardProc(ByVal idHook As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Check if key is pressed down
If wParam = WM_KEYDOWN Then
'Copy Memory of key to variable hookKey
Call CopyMemory(hookKey, ByVal lParam, Len(hookKey))
keyCode = hookKey.code
'Check array for key
For i = 0 To 21
If keyCode = keyChar(i) Then keys = keys & "[" & keyList(i) & "]"
Next
For i = 22 To 47
If keyCode = keyChar(i) Then keys = keys & keyList(i)
Next
'Letters and numbers
If (keyCode >= 48 And keyCode <= 57) Or (keyCode >= 65 And keyCode <= 90) Then
keys = keys & Chr(keyCode)
ElseIf keyCode = 13 Then
keys = keys & vbNewLine & vbTab
End If
'If the message is not one we want to trap, pass it along
KeyboardProc = CallNextHookEx(hook, ncode, wParam, lParam)
End Function
'In a form, called Form1
Private Sub Form_Load()
'set a keyboard hook
hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf KeyboardProc, App.hInstance, App.ThreadID)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'remove the windows-hook
UnhookWindowsHookEx hHook
End Sub
Please find out the solution for me ....
Thanking