微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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代码项目文章.

原文地址:https://www.jb51.cc/csharp/99888.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐