Nascondere o visualizzare la TaskBar di Windows7 con PInvoke
Scritto da
Massimo Bonanni il
mercoledì 9 novembre 2011
•
Linguaggio:
• Livello: 100
A volte si ha la necessità di dover nascondere la
TaskBar di Windows e per fare questo possiamo
ricorrere alla tecnica di PInvoke.
E' sufficiente richiamare opportunamente le API
FindWindow e ShowWindow:
VB.NET
<DllImport("user32.dll")>
Private Shared Function FindWindow(className As String, windowText As String) As IntPtr
End Function
<DllImport("user32.dll")>
Private Shared Function ShowWindow(hwnd As IntPtr, command As Integer) As Integer
End Function
Private Const SW_HIDE As Integer = 0
Private Const SW_SHOW As Integer = 1
In particolare, i metodi per nascondere e visualizzare la
TaskBar sono:
VB.NET
Public Function HideTaskBar() As Boolean
Dim retval = False
Dim hwndTaskBar = FindWindow("Shell_TrayWnd", "")
If hwndTaskBar <> IntPtr.Zero Then
retval = ShowWindow(hwndTaskBar, SW_HIDE)
End If
Return retval
End Sub
Public Function ShowTaskBar() As Boolean
Dim retval = False
Dim hwndTaskBar = FindWindow("Shell_TrayWnd", "")
If hwndTaskBar <> IntPtr.Zero Then
retval= ShowWindow(hwndTaskBar, SW_SHOW)
End If
Return retval
End Sub
Tags: PInvoke,user32,Windows API