1

如何在 vb.net 的任务栏中隐藏我的应用程序的进程?我试过了,但没有成功。

我的编码如下:

Public Class TaskBarManager
    <ComImport(), Guid("56fdf342-fd6d-11d0-958a-006097c9a090"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
    Public Interface ITaskbarList
        Sub HrInit()
        Sub AddTab(<[In]()> ByVal hWnd As IntPtr)
        Sub DeleteTab(<[In]()> ByVal hWnd As IntPtr)
        Sub ActivateTab(<[In]()> ByVal hWnd As IntPtr)
        Sub SetActiveAlt(<[In]()> ByVal hWnd As IntPtr)
    End Interface
    <ComImport()> _
    <Guid("56fdf344-fd6d-11d0-958a-006097c9a090")> _
    Public Class CoTaskbarList
    End Class
    Public Shared Sub HideProcessFromTaskBar(ByVal PID As Integer)
        Dim taskbarList As ITaskbarList = DirectCast(New CoTaskbarList(), ITaskbarList)
        taskbarList.HrInit()
        taskbarList.DeleteTab(Process.GetProcessById(PID).MainWindowHandle)
    End Sub
    Public Shared Sub ShowProcessInTaskBar(ByVal PID As Integer)
        Dim taskbarList As ITaskbarList = DirectCast(New CoTaskbarList(), ITaskbarList)
        taskbarList.HrInit()
        taskbarList.AddTab(Process.GetProcessById(PID).MainWindowHandle)
    End Sub
4

0 回答 0