5

vb.netのタスクバーで作業プロセスのアイコンを非表示にする方法は?

Dim startInfo As New ProcessStartInfo("Some Process")
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden 'he hide only window of process
'startInfo.ShowInTaskbar = False 'don't work with System.Diagnostics and ProcessStartInfo
Pr = System.Diagnostics.Process.Start(startInfo)

タスクバーのウィンドウとアイコンを非表示にする必要があります。助けてください。

4

1 に答える 1

3

同じ問題を解決しようとしているこの投稿を見つけました:

Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Module Module1

    Public GWL_EXSTYLE As Integer = -20
    Public WS_EX_APPWINDOW As Integer = &H40000

    <DllImport("user32.dll")> _
    Public Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    End Function

    <DllImport("user32.dll")> _
    Public Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    End Function

    <DllImport("user32.dll", SetLastError:=True)> _
    Public Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
    End Function

    Sub Main()

        ' Start your process
        Dim startInfo As New ProcessStartInfo("YourProcessName")
        startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
        Dim p as Process = System.Diagnostics.Process.Start(startInfo)            

        ' Hide the process from the task bar
        Dim style As Integer = (GetWindowLong(p.MainWindowHandle, GWL_EXSTYLE) And Not WS_EX_APPWINDOW)
        SetWindowLong(p.MainWindowHandle, GWL_EXSTYLE, style)
        SetParent(p.MainWindowHandle, New Form().Handle)

    End Sub

End Module
于 2013-02-06T11:13:01.540 に答える