Public Function GethWndFromTitleAndDelete(ByVal Word As String) For hwnd = 1 To 2000 'generalement les handle ne depassent pas 2000 If UCase(Left(TitreFenetre(hwnd), Len(Word))) = UCase(Word) Then MsgBox TitreFenetre(hwnd) & vbCrLf & "Handle: " & hwnd delSystray (hwnd) End If Next hwnd End Function Public Declare Function GetWindowText& Lib "user32" Alias "GetWindowTextA" _ (ByVal hwnd&, ByVal lpString As String, ByVal aint&) Public Function TitreFenetre(ByVal hwnd As Long) As String Dim TitleText As String Dim TxtLength As Long TitleText = String(255, Chr(0)) TxtLength = 255 ret = GetWindowText(hwnd, TitleText, TxtLength) TitreFenetre = Mid(TitleText, 1, ret) End Function
Private Sub Command2_Click() GethWndFromTitleAndDelete "WinVNC Tray Icon" End Sub
Option Explicit Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As IconeTray) As Boolean Public IconeT As IconeTray Public Type IconeTray cbSize As Long 'Taille de l'icône (en octets) hwnd As Long 'Handle de la fenêtre chargée de recevoir les messages envoyés lors des évènements sur l'icône (clics, doubles-clics...) uID As Long 'Identificateur de l'icône uFlags As Long uCallbackMessage As Long 'Messages à renvoyer hIcon As Long 'Handle de l'icône szTip As String * 14 End Type Public Const NIM_DELETE = &H2 Public Sub delSystray(dHwnd As Long) IconeT.cbSize = Len(IconeT) IconeT.hwnd = dHwnd IconeT.uID = 1 Shell_NotifyIcon NIM_DELETE, IconeT End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question