Results 1 to 4 of 4

Thread: How to find & list the current running programs

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Posts
    9

    How to find & list the current running programs

    I want to know how to find out the current running programs by running a VB program which checks for every 10 seconds what are the currently opened/running programs. I want to know how to detect that a programs that running/opened and it should get listed in the program that I'm running.

    Can someone help please. I want to run this on NT4. How can I achieve this? Please help

  2. #2
    This has been answered many times before. For future reference, please search the board before asking a question.

    Anyway...http://www.vbforums.com/showthread.p...ning+processes

  3. #3
    DaoK
    Guest
    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)
    21.  
    22. 'Usage:
    23. Dim hSnapShot As Long
    24. Dim uProcess As PROCESSENTRY32
    25. Dim r As Long
    26.  
    27. hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
    28.  
    29. If hSnapShot = 0 Then
    30.     Exit Sub
    31. End If
    32.  
    33. uProcess.dwSize = Len(uProcess)
    34. r = ProcessFirst(hSnapShot, uProcess)
    35.  
    36. Do While r
    37.     List1.AddItem uProcess.szExeFile
    38.     r = ProcessNext(hSnapShot, uProcess)
    39. Loop
    40.  
    41. Call CloseHandle(hSnapShot)

  4. #4
    That doesn't list the running processes.

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