I want to check if an icon exists in systray; as if the "X" application displays the systray icon in the systray area.
I have Googled to get information on how to do this, but I haven't found anything.
UPDATE:
This is what I tried in VB.NET translating C # url examples received by Robert's 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
Elektrostudios
source share