gpt4 book ai didi

c# - 图标存在于系统托盘中?

转载 作者:太空狗 更新时间:2023-10-29 20:34:09 26 4
gpt4 key购买 nike

我想检查系统托盘中是否存在图标;例如,如果“X”应用程序在系统托盘区域中显示了它们的系统托盘图标。

我在谷歌上搜索了有关如何执行此操作的信息,但没有找到任何内容。

UPDATE :



这是我在 VB.NET 中尝试翻译 Robert 评论给出的 url 的 C# 示例,但我不知道如何继续。
Imports System.Runtime.InteropServices

Public Class Form1

Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Public Shared Function WindowHandle(sTitle As String) As Long
Return FindWindow(vbNullString, sTitle)
End Function


Private Shared Function GetSystemTrayHandle() As IntPtr
Dim hWndTray As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
If hWndTray <> IntPtr.Zero Then
hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "TrayNotifyWnd", Nothing)
If hWndTray <> IntPtr.Zero Then
hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "SysPager", Nothing)
If hWndTray <> IntPtr.Zero Then
hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "ToolbarWindow32", Nothing)
Return hWndTray
End If
End If
End If

Return IntPtr.Zero
End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox(WindowHandle("Steam")) ' 6687230
MsgBox(GetSystemTrayHandle()) ' 62789
End Sub

End Class

最佳答案

您应该阅读 this代码项目文章。

关于c# - 图标存在于系统托盘中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15908108/

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