This code fills the listbox passed in with a list of the process names running on the current system.

VB Code:
  1. Const TH32CS_SNAPHEAPLIST = &H1
  2.     Const TH32CS_SNAPPROCESS = &H2
  3.     Const TH32CS_SNAPTHREAD = &H4
  4.     Const TH32CS_SNAPMODULE = &H8
  5.     Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
  6.     Const TH32CS_INHERIT = &H80000000
  7.     Const MAX_PATH As Integer = 260
  8.     Private Type PROCESSENTRY32
  9.         dwSize As Long
  10.         cntUsage As Long
  11.         th32ProcessID As Long
  12.         th32DefaultHeapID As Long
  13.         th32ModuleID As Long
  14.         cntThreads As Long
  15.         th32ParentProcessID As Long
  16.         pcPriClassBase As Long
  17.         dwFlags As Long
  18.         szExeFile As String * MAX_PATH
  19.     End Type
  20.  
  21.     Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
  22.     Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
  23.     Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
  24.  
  25.     Private Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, ByVal cb As Long, ByRef cbNeeded As Long) As Long
  26.     Private Declare Function GetModuleBaseName Lib "psapi.dll" _
  27.  
  28. Private Function GetProcessNameFromId(ByVal ProcId As Long) As String
  29.  
  30.     Private Declare Function GetModuleBaseName Lib "psapi.dll" _
  31.               Alias "GetModuleBaseNameA" _
  32.                         (ByVal hProcess As Long, _
  33.                          ByVal hModule As Long, _
  34.                          ByVal lpBaseName As String, _
  35.                          ByVal nSize As Long) As Long
  36.  
  37.     Private Declare Function EnumProcessModules Lib "psapi.dll" _
  38.                         (ByVal hProcess As Long, _
  39.                          lphModule As Long, _
  40.                          ByVal cb As Long, _
  41.                          lpcbNeeded As Long) As Long
  42.  
  43.  
  44. Dim lngModuleHandle As Long
  45. Dim lngReturnValue As Long
  46. Dim strProcessName As String
  47. Dim hProc As Long
  48. Dim lngNumberOfBytesReceived As Long
  49.  
  50. hProc = OpenProcess(PROCESS_ALL_ACCESS, False, ProcId)
  51.  
  52.         lngModuleHandle = 0
  53.         lngReturnValue = EnumProcessModules(hProc, lngModuleHandle, 4&, lngNumberOfBytesReceived)
  54.         If Err.LastDllError Then
  55.             Debug.Print LastSystemError
  56.         End If
  57.        
  58.         ' Get the name of the module
  59.         strProcessName = String$(256, 0)
  60.         lngReturnValue = GetModuleBaseName(hProc, lngModuleHandle, strProcessName, Len(strProcessName))
  61.         If Err.LastDllError Then
  62.             Debug.Print LastSystemError
  63.         End If
  64.        
  65. CloseHandle hProc
  66.  
  67. GetProcessNameFromId = Trim$(strProcessName)
  68.  
  69. End Function
  70.  
  71. Public Sub FillProcessList(ByVal lstIn As ListBox)
  72.  
  73. Dim hSnapShot As Long
  74. Dim uProcess As PROCESSENTRY32
  75. Dim r As Boolean
  76. Dim strProcName As String
  77.  
  78. On Error GoTo OldWindowsversion
  79.  
  80. '\\Takes a snapshot of the processes and the heaps, modules, and threads used by the processes
  81. hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&)
  82. '\\set the length of our ProcessEntry-type
  83. uProcess.dwSize = Len(uProcess)
  84. '\\Retrieve information about the first process encountered in our system snapshot
  85. r = Process32First(hSnapShot, uProcess)
  86. Do While r
  87.     strProcName = UCase(Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile, Chr$(0)) > 0, InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0)))
  88.     If Trim$(strProcName) <> "" Then
  89.         lstIn.AddItem strProcName
  90.         lstIn.ItemData(lstIn.NewIndex) = uProcess.th32ProcessID
  91.     End If
  92.     '\\Retrieve information about the next process recorded in our system snapshot
  93.     r = Process32Next(hSnapShot, uProcess)
  94. Loop
  95. 'close our snapshot handle
  96. CloseHandle hSnapShot
  97.  
  98. Exit Sub
  99.  
  100. OldWindowsversion:
  101.     Dim proclst() As Long
  102.     Dim lBytesRequired As Long, lItem As Long
  103.     ReDim proclst(256) As Long
  104.     Dim sName As String
  105.    
  106.     r = EnumProcesses(proclst(0), UBound(proclst) * 4, lBytesRequired)
  107.     If lBytesRequired > (UBound(proclst) * 4) Then
  108.         ReDim proclst(lBytesRequired / 4) As Long
  109.         r = EnumProcesses(proclst(0), UBound(proclst) * 4, lBytesRequired)
  110.     End If
  111.     For lItem = 0 To UBound(proclst)
  112.         If proclst(lItem) <> 0 Then
  113.             sName = GetProcessNameFromId(proclst(lItem))
  114.             If sName <> "" And InStr(sName, "?") = 0 Then
  115.                 lstIn.AddItem sName
  116.                 lstIn.ItemData(lstIn.NewIndex) = proclst(lItem)
  117.             End If
  118.         End If
  119.     Next lItem
  120.  
  121. End Sub

Hope this is useful,
Duncan