borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Disable right click for taskbar using vb.net)Next Topic (FTP Upload problem) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : disable STARTMENU
Poster Message
babyg
Level: Scholar

Registered: 15-10-2003
Posts: 33

Ads by Lake Quincy Media
icon disable STARTMENU

Hi.,
How can i disable the STARTMENU using VB2008/VB.net?

I found a code that would disable the Windows keys... however, CTRL+ESC still activates the startmenu.

Please help.

____________________________
help... im a fish.

Ads by Lake Quincy Media
09-11-2009 at 05:34 AM
View Profile Send Email to User Show All Posts | Quote Reply
iliekater
Level: Master

Registered: 04-02-2005
Posts: 146
icon Re: disable STARTMENU

Oh mine , this sounds suspicious   ...

29-12-2009 at 11:54 PM
View Profile Send Email to User Show All Posts | Quote Reply
raju.145in
Level: Trainee

Registered: 08-02-2010
Posts: 2
icon 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

08-02-2010 at 01:33 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB.Net : disable STARTMENU
Previous Topic (Disable right click for taskbar using vb.net)Next Topic (FTP Upload problem) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder