【问题标题】:Icon exists in systray?图标存在于系统托盘中?
【发布时间】:2013-04-09 17:05:17
【问题描述】:

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

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

更新:

这是我在 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

【问题讨论】:

  • 您想为您的应用程序或第 3 方应用程序执行此操作吗?
  • 感谢您的评论,适用于第 3 方应用
  • @Robert 谢谢,但我完全听不懂
  • 我必须在我的实验室中复制它才能向您解释。可能会涉及蝙蝠翅膀的提取物。

标签: c# vb.net visual-studio system-tray systray


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    • 2011-06-25
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-16
    相关资源
    最近更新 更多