Disable Windows Key [Resolved]
I made an app that allows me not to logoff my WinXP computer at work. The Form is always on top and it asks for a password to access Windows. It just saves keep logging off and on evertime I leave the computer.
My problem is while the app is running if you press the Windows key the Start menu pops up. All other keys are disabled Ctrl+Esc, Ctrl+Tab etc. I've even sorted out Taskmanger so it can't be end tasked. I think the Keyascii is 91 for this key.
The app works perfect with Win98 but with WinXP the Windows key is still active.
Thanks. ;)
Re: Disable Windows Key [Resolved]
hello keithuk,i am developing an application for hook keyboard,so it disables special key combinations,for example CTRL+ALT+DEL,ALT+TAB...
in my application there is a number of checkboxes,one for each key combination,but the application do not work in the just manner.
i have problems about understanding this procedure, i put the code,if someone would give me an help i will be very pleased...
Private Function Keyboard_Proc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Dim bProc As Boolean = False
Select Case wParam
Case 256, 257, 260, 261
'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
bProc = ((lParam.vkCode = 9) AndAlso (lParam.flags = 32)) Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 32)) Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 0)) Or _
((lParam.vkCode = 91) AndAlso (lParam.flags = 1)) Or _
((lParam.vkCode = 92) AndAlso (lParam.flags = 1))
End Select
If bProc = True Then
Return 1
Else
Return CallNextHookEx(0, nCode, wParam, lParam)
End If
End Function
i do not understand the values of "lparam.flags", why 0 or 1 or 32???
enri
Re: Disable Windows Key [Resolved]
@Joacim
why do i get this compiler error "Invalid use of AddressOf Operator"?
in this line:
VB Code:
hKeyb = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeybCallback, App.hInstance, 0&)
did i missed something? i just copied and pasted your code...
Edit:
ok got it now...the code must be in a module :D
Re: Disable Windows Key [Resolved]
Quote:
Originally Posted by ogagsme
ok got it now...the code must be in a module :D
Correct. All hooks and callbacks in VB must reside in a regular BAS module. They can not be in any form of class modules (and a Form is a sort of class module), the reason for this is that a class have a reference counter to keep track of the number of references it has. But a callback is called by an external thread and doesn't have a reference to any object.