• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 574
  • Last Modified:

Disable Start Menu

I have an ACCESS XP application that is run on a public access machine.  We want to prevent users from accessing the start menu/task manager whilst the application is running.  Is there any VB.NET/VB6/Access XP API/Code or indeed a Systems Administration technique to prevent the start menu from being accessed ?
0
CanisEsco
Asked:
CanisEsco
  • 4
  • 3
  • 2
  • +2
2 Solutions
 
RonaldBiemansCommented:
Option Strict On
Option Explicit On

Imports System.Runtime.InteropServices

Public Class NativeMethods

<DllImport("user32.dll", EntryPoint:="FindWindowA")> _
Public Overloads Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
End Function

<DllImport("user32.dll", EntryPoint:="FindWindowExA")> _
Public Overloads Shared Function FindWindow(ByVal hwndParent As IntPtr, ByVal hwndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As IntPtr
End Function

<DllImport("user32.dll", EntryPoint:="EnableWindow")> _
Public Shared Function EnableWindow(ByVal hWnd As IntPtr, ByVal bEnable As Boolean) As Boolean
End Function

<DllImport("user32.dll", EntryPoint:="IsWindowEnabled")> _
Public Shared Function IsWindowEnabled(ByVal hWnd As IntPtr) As Boolean

End Function

End Class

Public Class Security

Private Const ShellTrayClassName As String = "Shell_TrayWnd"

Private Shared Function FindStartButton() As IntPtr
Return NativeMethods.FindWindow(NativeMethods.FindWindow(ShellTrayClassName, Nothing), Nothing, "Button", Nothing)
End Function

Public Shared Function IsStartButtonEnabled() As Boolean
Return NativeMethods.IsWindowEnabled(FindStartButton)
End Function

Public Shared Function EnableStartButton() As Boolean
Dim StartButtonhwnd As IntPtr = FindStartButton()

If Not StartButtonhwnd.Equals(IntPtr.Zero) Then
Return NativeMethods.EnableWindow(StartButtonhwnd, True)
End If
End Function

Public Shared Function DisableStartButton() As Boolean
Dim StartButtonhwnd As IntPtr = FindStartButton()

If Not StartButtonhwnd.Equals(IntPtr.Zero) Then
Return NativeMethods.EnableWindow(StartButtonhwnd, False)
End If
End Function

End Class

This will allow you to disable/enable  the start button (but only the start button), There a many ways to get around this and not all of them can be disabled
0
 
CanisEscoAuthor Commented:
That's top, just need to disable the taskbar and task manager...
0
 
flavoCommented:
You can use this in VBA... Dont forget to turn it back on :-)

http://www.programmershelp.co.uk/vbhidetask.php
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Fernando SotoRetiredCommented:
This will hide the task bar from showing up.

    Private Declare Unicode Function FindWindowW Lib "user32" _
        (ByVal lpClassName As String, _
         ByVal lpWindowName As String) As Integer

    Private Declare Unicode Function SetWindowPos Lib "user32" (ByVal hWnd As Integer, _
        ByVal hWndInsertAfter As Integer, _
        ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, _
        ByVal cy As Integer, ByVal wFlags As Integer) As Integer

    Const TOGGLE_HIDE As Integer = &H80
    Const TOGGLE_UNHIDE As Integer = &H40
    Private hTaskWindow As Integer

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

        hTaskWindow = FindWindowW("Shell_traywnd", "")

    End Sub

    Private Sub cbHide_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles cbHide.Click

        ' This statement will hide the task bar until you enable it again
        SetWindowPos(hTaskWindow, 0, 0, 0, 0, 0, TOGGLE_HIDE)

    End Sub

    Private Sub cbUnHide_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles cbUnHide.Click

        ' Enables the task bar again
        SetWindowPos(hTaskWindow, 0, 0, 0, 0, 0, TOGGLE_UNHIDE)

    End Sub


Hope this helps
0
 
Fernando SotoRetiredCommented:
My code will not display the task bar at all so don't forget to unhide it.
0
 
CanisEscoAuthor Commented:
How do we disable the key now.  When I press the windows key on the keyboard, the Start Menu appears, how do we disable that pls.
0
 
flavoCommented:
   Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean

        If msg.WParam.ToInt32() = CInt(Keys.LWin) Or msg.WParam.ToInt32() = CInt(Keys.RWin) Then

            'nothing
            Return True

        End If

        Return MyBase.ProcessCmdKey(msg, keyData)

    End Function 'ProcessCmdKey
0
 
Fernando SotoRetiredCommented:
I was not able to find a way to hide / disable the Start Menu. I did come accross a Freeware program that does what you want. You may want to download it and give it a try.

http://www.bytegems.com/ihatethiskey.shtml

I will ask around how this may be done seeming it is possable.
0
 
Fernando SotoRetiredCommented:
Hi Bob;

I would like to see a resolution on this question seeming the question has been answered.

Thanks;
Fernando
0
 
CanisEscoAuthor Commented:
The resolution that we used in the end was a mix of Ronald and Fernando's solution.  We used the code from Ronald and the application from Fernando.  I've increased and shared the points.  The actual requirement at work had been forgotten about hence the reason for not closing.  Cheers for the advise.
0
 
dserpentiniCommented:
Hi flavo, i'll appreciatte if you can give an idea how to use your function code to disable the Windows keboard key.

thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now