?
Solved

Disable Start Menu

Posted on 2005-05-10
12
Medium Priority
?
529 Views
Last Modified: 2012-06-27
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
Comment
Question by:CanisEsco
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 150 total points
ID: 13967137
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
 

Author Comment

by:CanisEsco
ID: 13967166
That's top, just need to disable the taskbar and task manager...
0
 
LVL 34

Expert Comment

by:flavo
ID: 13969354
You can use this in VBA... Dont forget to turn it back on :-)

http://www.programmershelp.co.uk/vbhidetask.php
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 64

Expert Comment

by:Fernando Soto
ID: 13969867
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
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 13974780
My code will not display the task bar at all so don't forget to unhide it.
0
 

Author Comment

by:CanisEsco
ID: 13975813
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
 
LVL 34

Expert Comment

by:flavo
ID: 13980261
   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
 
LVL 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 150 total points
ID: 13981931
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
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 14237344
Hi Bob;

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

Thanks;
Fernando
0
 

Author Comment

by:CanisEsco
ID: 14238210
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
 

Expert Comment

by:dserpentini
ID: 24224711
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question