Option Explicit
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 260
End Type
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private sTareas() As String
Private Sub GetProcesos()
Dim lSnapShot As Long
lSnapShot = CreateToolhelpSnapshot(2&, 0&)
If lSnapShot <> 0 Then
Dim Proceso As PROCESSENTRY32
Proceso.dwSize = Len(Proceso)
Dim lRc As Long, lCta As Long
lRc = ProcessFirst(lSnapShot, Proceso)
Do While lRc
lCta = lCta + 1
If lCta > 1 Then
ReDim Preserve sTareas(2, lCta)
Else
ReDim sTareas(2, 1)
End If
sTareas(0, lCta - 1) = Proceso.th32ProcessID
sTareas(1, lCta - 1) = Left(Proceso.szExeFile, InStr(Proceso.szExeFile, Chr(0)) - 1)
lRc = ProcessNext(lSnapShot, Proceso)
Loop
CloseHandle lSnapShot
End If
End Sub