加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 07:54:16 所属栏目:百科 来源:网络整理
导读:我想检查系统托盘中是否存在图标;如果“X”应用程序在系统托盘区域中显示了他们的系统托盘图标. 我已经用Google搜索了有关如何执行此操作的信息,但我没有找到任何内容. UPDATE : 这是我在VB.NET中尝试翻译由Robert评论给出的网址的C#示例,但我不知道如何继续
我想检查系统托盘中是否存在图标;如果“X”应用程序在系统托盘区域中显示了他们的系统托盘图标.

我已经用Google搜索了有关如何执行此操作的信息,但我没有找到任何内容.

UPDATE :

这是我在VB.NET中尝试翻译由Robert评论给出的网址的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,"SysPager",Nothing)
                If hWndTray <> IntPtr.Zero Then
                    hWndTray = FindWindowEx(hWndTray,"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代码项目文章.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读