Results 1 to 3 of 3

Thread: Getting list of all running programs...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    109

    Getting list of all running programs...

    I'm making a program that will scan threw all the programs the computer is running. Like all of the programs in the "Close Program" dialog (ctrl+alt+del). Once I get the list, I need to get the path of all the exe's for each program, so I can scan threw the file, kind of like a virus scanner does. How would I go about getting the file path's of all the running programs?

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    I've been told this doesn't work on NT, but it does work on 95/98. You'll need a listbox on a form

    Paste this into a module
    VB Code:
    1. Public Const TH32CS_SNAPPROCESS As Long = 2&
    2. Public Const MAX_PATH As Integer = 260
    3.  
    4. Public Type PROCESSENTRY32
    5.     dwSize As Long
    6.     cntUsage As Long
    7.     th32ProcessID As Long
    8.     th32DefaultHeapID As Long
    9.     th32ModuleID As Long
    10.     cntThreads As Long
    11.     th32ParentProcessID As Long
    12.     pcPriClassBase As Long
    13.     dwFlags As Long
    14.     szExeFile As String * MAX_PATH
    15. End Type
    16.  
    17. Public Declare Function CreateToolhelpSnapshot Lib "Kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
    18. Public Declare Function ProcessFirst Lib "Kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
    19. Public Declare Function ProcessNext Lib "Kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
    20. Public Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
    Usage
    VB Code:
    1. Dim hSnapShot As Long
    2. Dim uProcess As PROCESSENTRY32
    3. Dim r As Long
    4.  
    5. hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
    6.  
    7. If hSnapShot = 0 Then
    8.     Exit Sub
    9. End If
    10.  
    11. uProcess.dwSize = Len(uProcess)
    12. r = ProcessFirst(hSnapShot, uProcess)
    13.  
    14. Do While r
    15.     List1.AddItem uProcess.szExeFile
    16.     r = ProcessNext(hSnapShot, uProcess)
    17. Loop
    18.  
    19. Call CloseHandle(hSnapShot)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    109
    OMG, ty so much! thats exactly what i wanted! yAy!

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