How can I hide the taskbar in Windows 10

后端 未结 1 1186
忘掉有多难
忘掉有多难 2021-01-26 12:47

I am currently making a deployment program in VB.net and I am having trouble hiding the taskbar. My code works in Windows 7, but it does not seem to work after the Windows 10 up

相关标签:
1条回答
  • 2021-01-26 13:30

    The reason your code is not working is that you're using deprecated function declarations. I tested your code with the proper declarations for FindWindow and SetWindowPos and everything is working fine (Windows 10 x64).

    Here's my code for reference:

    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
    
    0 讨论(0)
提交回复
热议问题