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'标志,以便任务栏不被调整大小或移动。 –