Author Topic: VB base code for processes running on pc  (Read 750 times)

0 Members and 1 Guest are viewing this topic.

CodeFuzion

  • Poptart
  • *
  • Posts: 2
    • View Profile
VB base code for processes running on pc
« on: July 28, 2004, 04:55:04 am »
This code will show you all the processes that is running on your pc


Obtaining a list of running processes
' In Microsoft Visual Basic 5/6

' ____________________________________

' Things to set up:
' =================

' Start a new project, and to the form
' add a listbox (List1), and a command
' button (Command1).

' ____________________________________

' BAS Module Code
' ===============

' Add the following code to a BAS module:
' ---------------------------------------

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)

' ____________________________________

' Form Code
' =========

' Add the following code to the form:
' -----------------------------------

Private Sub Command1_Click()

    Dim hSnapShot As Long
    Dim uProcess As PROCESSENTRY32
    Dim r As Long

    hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)

    If hSnapShot = 0 Then Exit Sub

    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


' ____________________________________

' Code Is Complete!
' =================

' To start, simply run the project, and click
' on the command button. This will fill up the
' listbox with the full exe path and filename
' of all the currently-running processes.
Have fun guys!!

Blizzard

  • Klass Klown
  • ***
  • Posts: 326
    • View Profile
VB base code for processes running on pc
« Reply #1 on: July 28, 2004, 01:26:01 pm »
Yeah it's very simple to make that on VB, thx for the info, it could be helpful for somebody uses VB :)

[TKC]thejoker

  • Master Heckler
  • *****
  • Posts: 2429
    • View Profile
VB base code for processes running on pc
« Reply #2 on: July 28, 2004, 10:48:24 pm »
i got VB but i really cant be bothered sitting reading that, ill stick with TMK  :P

M. O.

  • Administrator
  • MasstKer
  • *
  • Posts: 9185
    • View Profile
    • http://www.tkc-community.net
VB base code for processes running on pc
« Reply #3 on: July 29, 2004, 02:12:56 am »
Nice  :)

The idea and parts of the code can easily be converted to any other language.
Heckling is an art, and game hacking a science.