elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Systray in listview
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Systray in listview  (Leído 1,891 veces)
VanHan

Desconectado Desconectado

Mensajes: 41


.:: [ vHn ] ::.


Ver Perfil WWW
Systray in listview
« en: 7 Abril 2011, 18:56 pm »

Hola como dice el título es posible mostrar todos los iconos del Systray [el systray es donde esta el reloj de windows en la parte derecha de la barra de menú inicio o barra de tareas] en un ListView y q al darle click derecho sobre el Item seleccionado muestre las obciones correspondientes al mismo.

Salu2
[vHn]


En línea

.:: I'm GeeK ::.
seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: Systray in listview
« Respuesta #1 en: 8 Abril 2011, 02:47 am »

Hola, proba con esto, vos ponelo despues en un listview, lo que hace es enumerar los iconos del system tray, tambien te saca el nombre del proceso que pertenece al Hwnd de la ventana de cada proceso y el icono del mismo, y de paso te dice el tooltiptext que tiene el icono...en windows XP funciona bien.

Código
  1. Option Explicit
  2.  
  3. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  4. Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
  5. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
  6. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
  7. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  8. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  9. Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal dwFreeType As Long) As Long
  10. Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
  11. Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, Optional lpNumberOfBytesWritten As Long) As Long
  12. Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, Optional lpNumberOfBytesWritten As Long) As Long
  13. Private Declare Function EnumProcessModules Lib "psapi" (ByVal hProcess As Long, ByRef lphModule As Long, ByVal cb As Long, ByRef lpcbNeeded As Long) As Long
  14. Private Declare Function GetModuleFileNameEx Lib "psapi" Alias "GetModuleFileNameExA" (ByVal hProcess As Long, ByVal hModule As Long, ByVal ModuleName As String, ByVal nSize As Long) As Long
  15.  
  16. Const PROCESS_QUERY_INFORMATION = (&H400)
  17. Const PROCESS_VM_READ = (&H10)
  18. Const PROCESS_VM_WRITE = (&H20)
  19. Const PROCESS_VM_OPERATION = (&H8)
  20. Const MEM_COMMIT = &H1000
  21. Const MEM_RESERVE = &H2000
  22. Const MEM_RELEASE = &H8000
  23. Const PAGE_READWRITE = &H4
  24. Const MAX_PATH = 260
  25. Const WM_USER = &H400
  26. Const TB_BUTTONCOUNT = (WM_USER + 24)
  27. Const TB_GETBUTTON = (WM_USER + 23)
  28. Const TB_GETBUTTONTEXTA = (WM_USER + 45)
  29.  
  30. Private Type TBBUTTON
  31.    iBitmap As Long
  32.    idCommand As Long
  33.    fsState As Byte
  34.    fsStyle As Byte
  35.    dwData As Long
  36.    iString As Long
  37. End Type
  38.  
  39. Private Type TRAYDATA
  40.    hWnd  As Long
  41.    uID As Long
  42.    uCallbackMessage As Long
  43.    Reserved1 As Long
  44.    Reserved2 As Long
  45.    hIcon As Long
  46. End Type
  47.  
  48. Private Sub Form_Load()
  49.    Dim hSysTray As Long, pID As Long, hProcess As Long, N As Long, Y As Long, L As Long
  50.    Dim tbb As TBBUTTON, lptbb As Long, td As TRAYDATA, lptd As Long, S As String * 128
  51.  
  52.    BackColor = vbWhite
  53.    AutoRedraw = True
  54.    hSysTray = GetNotificationWindow
  55.    GetWindowThreadProcessId hSysTray, pID
  56.    hProcess = OpenProcess(PROCESS_VM_READ Or PROCESS_VM_WRITE Or PROCESS_VM_OPERATION, 0, pID)
  57.    lptbb = VirtualAllocEx(hProcess, ByVal 0&, Len(tbb), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)
  58.    lptd = VirtualAllocEx(hProcess, ByVal 0&, Len(td), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)
  59.    L = VirtualAllocEx(hProcess, ByVal 0&, Len(S), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)
  60.    N = SendMessage(hSysTray, TB_BUTTONCOUNT, 0, ByVal 0&)
  61.  
  62.    For N = 0 To N - 1
  63.        SendMessage hSysTray, TB_GETBUTTON, N, ByVal lptbb
  64.        SendMessage hSysTray, TB_GETBUTTONTEXTA, N, ByVal L
  65.        ReadProcessMemory hProcess, ByVal L, ByVal S, Len(S)
  66.        Debug.Print Split(S, vbNullChar)(0)
  67.        ReadProcessMemory hProcess, ByVal lptbb, tbb, Len(tbb)
  68.        ReadProcessMemory hProcess, ByVal tbb.dwData, td, Len(td)
  69.  
  70.        If (td.Reserved1 And 1) = 0 Then
  71.            DrawIconEx hdc, 2, Y, td.hIcon, 16, 16, 0, 0, 3
  72.            CurrentX = 20 * Screen.TwipsPerPixelX
  73.            CurrentY = (Y + 2) * Screen.TwipsPerPixelY
  74.            Print GetProcessNameFromHwnd(td.hWnd)
  75.            Y = Y + 18
  76.        End If
  77.    Next
  78.  
  79.    VirtualFreeEx 0, lptbb, 0, MEM_RELEASE
  80.    VirtualFreeEx 0, lptd, 0, MEM_RELEASE
  81.    CloseHandle hProcess
  82. End Sub
  83.  
  84. Private Function GetNotificationWindow() As Long
  85.    Dim H As Long
  86.    H = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
  87.    H = FindWindowEx(H, 0, "TrayNotifyWnd", vbNullString)
  88.    H = FindWindowEx(H, 0, "SysPager", vbNullString)
  89.    GetNotificationWindow = FindWindowEx(H, 0, "ToolbarWindow32", vbNullString)
  90. End Function
  91.  
  92. Private Function GetProcessNameFromHwnd(ByVal hWnd As Long) As String
  93.    Dim ProcessId As Long, hProcess As Long, hModule As Long, S As String * MAX_PATH
  94.    GetWindowThreadProcessId hWnd, ProcessId
  95.    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, ProcessId)
  96.    EnumProcessModules hProcess, hModule, 1, ByVal 0
  97.    GetModuleFileNameEx hProcess, hModule, S, MAX_PATH
  98.    GetProcessNameFromHwnd = Left$(S, InStr(S, vbNullChar) - 1)
  99.    CloseHandle hProcess
  100. End Function

saludos.



En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Minimizar al systray
Programación Visual Basic
XP. 2 1,487 Último mensaje 1 Agosto 2006, 00:39 am
por elmaro
modificar icono en systray
Programación Visual Basic
elmaro 1 1,314 Último mensaje 20 Agosto 2006, 04:03 am
por elmaro
(Source) Ocultador systray
Programación Visual Basic
revenge1252 0 1,394 Último mensaje 13 Febrero 2008, 14:00 pm
por revenge1252
Sobre Systray
Programación Visual Basic
CAR3S? 8 3,754 Último mensaje 16 Enero 2011, 02:26 am
por CAR3S?
minimizar en SYSTRAY
Scripting
Dsalomon 4 4,968 Último mensaje 7 Octubre 2013, 23:16 pm
por Eleкtro
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines