Disabling the Windows Start Button

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

This small code sample shows how to disable the Start Menu button through code, simply paste it into a BAS module and use :


'
' Paste this into a Code Mode (BAS)
'
option Explicit
'
private Declare Function FindWindowEx Lib "user32" _
        Alias "FindWindowExA" (byval hWnd1 as Long, byval hWnd2 as Long, _
        byval lpsz1 as string, byval lpsz2 as string) as Long
'
private Declare Function EnableWindow Lib "user32" (byval hwnd as Long, _
        byval fEnable as Long) as Long

public Sub EnableStartMenuButton(byval bEnable as Boolean)
'
' Don't forget to re-enable it !
'
    Dim lHwnd as Long
' 
    lHwnd = FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString)
    lHwnd = FindWindowEx(lHwnd, 0&, "Button", vbNullString)
    Call EnableWindow(lHwnd, bEnable)
'
End Sub
'
'

Make sure that you remember to re-enable the start menu button at some point or it could get very frustrating !

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read