gpt4 book ai didi

.net - 隐藏任务栏中工作进程的图标

转载 作者:行者123 更新时间:2023-12-02 08:29:26 25 4
gpt4 key购买 nike

如何在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)

我需要隐藏任务栏上的窗口和图标。请帮忙。

最佳答案

我找到了this post它试图解决同样的问题:

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

关于.net - 隐藏任务栏中工作进程的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14726826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com