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

c# – 图标存在于系统托盘中?,第1张

概述我想检查系统托盘中是否存在图标;如果“X”应用程序在系统托盘区域中显示了他们的系统托盘图标. 我已经用Google搜索了有关如何执行此 *** 作的信息,但我没有找到任何内容. UPDATE : 这是我在VB.NET中尝试翻译由Robert评论给出的网址的C#示例,但我不知道如何继续它. Imports System.Runtime.InteropServicesPublic Class Form1 我想检查系统托盘中是否存在图标;如果“X”应用程序在系统托盘区域中显示了他们的系统托盘图标.

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

UPDATE :

这是我在VB.NET中尝试翻译由Robert评论给出的网址的C#示例,但我不知道如何继续它.

imports System.Runtime.InteropServicesPublic 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 SubEnd Class
解决方法 您应该阅读 this代码项目文章. 总结

以上是内存溢出为你收集整理的c# – 图标存在于系统托盘中?全部内容,希望文章能够帮你解决c# – 图标存在于系统托盘中?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1244764.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存