Click to See Complete Forum and Search --> : [RESOLVED] Help in getting the process information
techie_krishna
Mar 3rd, 2006, 09:23 AM
Hi,
Its me again...
Can any body help me in getting the processes and servics that are runing on my computer. Pls help its urgent..
Regards.
the182guy
Mar 3rd, 2006, 12:33 PM
this gets the list of windows...
in module
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal Lparam As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal Lparam As Long) As Boolean
Dim Strcaption As String, NSize As Long
NSize& = GetWindowTextLength(hwnd&)
Strcaption$ = Space$(NSize& + 1)
If IsWindowVisible(hwnd&) = 1 Then
Call GetWindowText(hwnd&, Strcaption$, Len(Strcaption$))
If Strcaption$ <> Chr$(0) Then
frmMain.lstWindows.AddItem left$(Strcaption$, Len(Strcaption$) - 1)
End If
End If
EnumWindowsProc = True
End Function
in command button or anything..
lstWindows.Clear
Call EnumWindows(AddressOf EnumWindowsProc, 0&)
it wil add the window captions to the listbox named lstWindows
the182guy
Mar 3rd, 2006, 08:58 PM
if you want to get the list of process exe names, like you see in task manager, then do it like this...
i have a command button and a listbox on the form, this is my command button code
'Get the processes
Dim SnapShot As Long
Dim Process As PROCESSENTRY32
Process.dwSize = Len(Process) 'define the DWORD size
SnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) 'Get a snapshot of the processes
Process32First SnapShot, Process 'Get first process
List1.AddItem Process.szexeFile 'Add first process to list
While Process32Next(SnapShot, Process) 'while a next process exists, get it
List1.AddItem Process.szexeFile 'Add to list
Wend
put this in a bas module
'Snapshot API
Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, lProcessID As Long) As Long
'First process API
Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Boolean
'Next process API
Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Boolean
'flag for snapshot API, this flag tells it to only give us the processes, no threads
Public Const TH32CS_SNAPPROCESS As Long = 2&
'type which is used to store info about the process
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 * 260
End Type
techie_krishna
Mar 6th, 2006, 10:37 AM
thankx man .....
It really helped me a lot...
Thankx a lot again!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.