CrAzY hOuSe
Locos por la programación
Listar las tareas activas del ordenador.
.net

Syndication

Genera una lista con las tareas activas actualmente en el PC.

Esta función devuelve una cadena con las tareas activas separadas por el carácter "·".

Option Explicit
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, _
        ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Const GW_CHILD = 5
Const GW_HWNDFIRST = 0
Const GW_HWNDLAST = 1
Const GW_HWNDNEXT = 2
Const GW_HWNDPREV = 3
Const GW_OWNER = 4
Sub LoadTaskList()
    Dim CurrWnd As Long, Length As Long, ListItem As String
    
    ' Recoge el primer handle del primer programa en proceso
    ' solo los de primer nivel
    CurrWnd = GetWindow(Me.hwnd, GW_HWNDFIRST)
    
    ' Bucle mientras el handle devuelto por GetWindow sea valido
    While CurrWnd <> 0
        ' Devuelve la longitud del nombre de la tarea para crear el buffer
        Length = GetWindowTextLength(CurrWnd)
        
        'Recoge el nombre de la aplicación
        ListItem = Space$(Length + 1)
        Length = GetWindowText(CurrWnd, ListItem, Length + 1)
        
        ' Si devuelve un valor valido, se incluye en la lista
        If Length > 0 Then LoadTaskList = LoadTaskList & ListItem & "·"
        
        ' Recoge el siguiente indice de la lista de tareas
        CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
    Wend
End Sub

Posted vie, abr 28 2000 19:21 by Maverick
Filed under: ,

Add a Comment

(optional)  
(optional)
(required)  
Remember Me?
MavericK
Powered by Community Server (Non-Commercial Edition), by Telligent Systems