7
我想檢查系統托盤中是否存在圖標;如果「X」應用程序在系統托盤區域中顯示了其系統托盤圖標。圖標存在於系統托盤中?
我已經谷歌瞭解如何做到這一點,但我沒有找到任何信息。
UPDATE:
這是我在VB.NET已經試過紅粉羅伯特評論翻譯網址的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
你想爲你的應用程序或第三方應用程序嗎? – 2013-04-09 17:06:39
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/4c4f60ce-3573-433d-994e-9c17f95187f0/ – 2013-04-09 17:07:02
感謝您的意見,是爲第三方應用程序 – ElektroStudios 2013-04-09 17:07:03