0
我發現這個示例代碼來自另一個問題,但我不知道如何運行此代碼。當我把它粘貼到我的項目中時,我沒有任何錯誤,但是當我運行代碼時,它永遠不會破壞這個代碼。Vb.net隱藏Windows 10中的任務欄
How can I hide the taskbar in Windows 10
Imports System.Runtime.InteropServices
Module Module1
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Private Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True)>
Private Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As SetWindowPosFlags) As Boolean
End Function
<Flags>
Private Enum SetWindowPosFlags As UInteger
SynchronousWindowPosition = &H4000
DeferErase = &H2000
DrawFrame = &H20
FrameChanged = &H20
HideWindow = &H80
DoNotActivate = &H10
DoNotCopyBits = &H100
IgnoreMove = &H2
DoNotChangeOwnerZOrder = &H200
DoNotRedraw = &H8
DoNotReposition = &H200
DoNotSendChangingEvent = &H400
IgnoreResize = &H1
IgnoreZOrder = &H4
ShowWindow = &H40
End Enum
Sub Main()
Dim window As IntPtr = FindWindow("Shell_traywnd", "")
SetWindowPos(window, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosFlags.HideWindow)
End Sub
End Module
在SetWindowPos(window,..)上放置一個斷點。 。)'行並確認'window'不是零。您可能也想要應用'IgnoreMove'和'IgnoreResize'標誌,以便任務欄不被調整大小或移動。 –