Icon exists in systray?
I want to check if an icon exists in the systray; as in, if "X" application has displayed their systray icon in the systray area.
I've Googled for information about how to do this but I didn't find anything.
UPDATE :
This what I've tried in VB.NET translating the C# examples of the url gived by Robert comment, but I don't know how to continue it.
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
你应该阅读这个代码项目文章。
链接地址: http://www.djcxy.com/p/12756.html下一篇: 图标存在于系统托盘中?