raju.145in Level: Trainee
 Registered: 08-02-2010 Posts: 2
|
Re: disable STARTMENU
StartButton(False) ' For hiding start menu
StartButton(True) '' For visible start menu
'Disable/Enable Start button
Public Sub StartButton(ByRef show As Boolean)
Dim primo As Integer
Dim ultimo As Integer
primo = FindWindow("Shell_TrayWnd", "")
ultimo = FindWindowEx(primo, 0, "Button", vbNullString)
If show = True Then
ShowWindow(ultimo, 5) 'show start button
Else
ShowWindow(ultimo, 0) 'hide start button
End If
End Sub
and now code to block ctl+ Esc keys
'System level functions to be used for hook and unhook keyboard input
Private Delegate Function LowLevelKeyboardProc(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function SetWindowsHookEx(ByVal id As Integer, ByVal callback As LowLevelKeyboardProc, ByVal hMod As IntPtr, ByVal dwThreadId As UInteger) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function UnhookWindowsHookEx(ByVal hook As IntPtr) As Boolean
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function CallNextHookEx(ByVal hook As IntPtr, ByVal nCode As Integer, ByVal wp As IntPtr, ByVal lp As IntPtr) As IntPtr
End Function
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function GetModuleHandle(ByVal name As String) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function GetAsyncKeyState(ByVal key As Keys) As Short
End Function
'Declaring Global objects
Private ptrHook As IntPtr
Private objKeyboardProcess As LowLevelKeyboardProc
Public Sub New()
Dim objCurrentModule As ProcessModule = Process.GetCurrentProcess().MainModule
'Get Current Module
objKeyboardProcess = New LowLevelKeyboardProc(AddressOf captureKey)
'Assign callback function each time keyboard process
ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0)
'Setting Hook of Keyboard Process for current module
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Private Function captureKey(ByVal nCode As Integer, ByVal wp As IntPtr, ByVal lp As IntPtr) As IntPtr
If nCode >= 0 Then
Dim objKeyInfo As KBDLLHOOKSTRUCT = DirectCast(Marshal.PtrToStructure(lp, GetType(KBDLLHOOKSTRUCT)), KBDLLHOOKSTRUCT)
If objKeyInfo.key = Keys.RWin OrElse objKeyInfo.key = Keys.LWin Then
' Disabling Windows keys
Return CType(1, IntPtr)
End If
If objKeyInfo.key = Keys.ControlKey OrElse objKeyInfo.key = Keys.Escape Then
' Disabling Ctrl + Esc keys
Return CType(1, IntPtr)
End If
If objKeyInfo.key = Keys.Alt OrElse objKeyInfo.key = Keys.F4 Then
' Disabling Alt + F4 keys
'Return CType(1, IntPtr)
frmPassword.Visible = True
End If
If objKeyInfo.key = Keys.Alt OrElse objKeyInfo.key = Keys.Tab Then
' Disabling Alt + Tab keys
Return CType(1, IntPtr)
End If
End If
Return CallNextHookEx(ptrHook, nCode, wp, lp)
End Function
____________________________
Raj
|