'Hier zunächst die entsprechende Klasse:
'Auf Wunsch kann noch eine Sicherheitsabfrage eingeblendet
'werden.
'Den auskemmentierten Messageboxblock wieder einbinden
Option Strict On
Option Explicit On
Imports Microsoft.VisualBasic
Public Class clsHideTaskbar
Private Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Integer
Private Declare Auto Sub 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)
Public Sub TaskBarVisible(ByVal Visible As Boolean)
Dim Handle As Integer = FindWindow("Shell_TrayWnd", "")
If Visible = True Then
SetWindowPos(Handle, 0, 0, 0, 0, 0, 64)
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\" & _
My.Application.Info.CompanyName & "\" & _
My.Application.Info.ProductName & "\Tray", "Visible", "True")
Else
' If MessageBox.Show("You want to hide the Taskbar?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
SetWindowPos(Handle, 0, 0, 0, 0, 0, 128)
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\" & _
My.Application.Info.CompanyName & "\" & _
My.Application.Info.ProductName & "\Tray", "Visible", "False")
'End If
End If
End Sub
End Class
'Hier der Aufruf, realisiert durch ein Formular.
'Darauf bitte 2 Command Buttons anordnen,
'diese mit btnHide und btnShow benennen.
'Wird als Private declariert, damit die
'Variablen über die ganze Form zugreifbar sind
Private cls As New clsHideTaskbar
Private keyValue As Boolean
Private Sub btnHide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHide.Click
cls.TaskBarVisible(False)
End Sub
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
cls.TaskBarVisible(True)
End Sub
'Nun der Zugriff auf die Reg beim Prog-Start
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
keyValue = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\" & _
My.Application.Info.CompanyName & "\" & _
My.Application.Info.ProductName & "\Tray", "Visible", "")
If keyValue = False Then
cls.TaskBarVisible(False)
End If
Catch ex As Exception
End Try
End Sub