Results 1 to 2 of 2

Thread: Getting a list of processes

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    11
    Something like the list of processes you see when you press Ctrl-Alt-Del, how to do it?

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    You could use...

    ...this code mate!

    Code:
    Option Explicit
    Public Const TH32CS_SNAPPROCESS As Long = 2&
    Public Const MAX_PATH As Integer = 260
    
    Public 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 * MAX_PATH
    End Type
    
    Public Declare Function CreateToolhelpSnapshot Lib "Kernel32" _
    Alias "CreateToolhelp32Snapshot" _
    (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
    
    Public Declare Function ProcessFirst Lib "Kernel32" _
    Alias "Process32First" _
    (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
    
    Public Declare Function ProcessNext Lib "Kernel32" _
    Alias "Process32Next" _
    (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
    
    Public Declare Sub CloseHandle Lib "Kernel32" _
    (ByVal hPass As Long)
    
    Private Sub cmdTasks_Click()
    
    Dim hSnapShot As Long
    Dim uProcess As PROCESSENTRY32
    Dim r As Long
    
    hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
    
    If hSnapShot = 0 Then
      Exit Sub
    End If
    
    uProcess.dwSize = Len(uProcess)
    
    r = ProcessFirst(hSnapShot, uProcess)
    
    Do While r
      List1.AddItem uProcess.szExeFile
      r = ProcessNext(hSnapShot, uProcess)
    Loop
    
    Call CloseHandle(hSnapShot)
    
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width