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.
Printable View
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.
this gets the list of windows...
in module
VB Code:
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..
VB Code:
lstWindows.Clear Call EnumWindows(AddressOf EnumWindowsProc, 0&)
it wil add the window captions to the listbox named lstWindows
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
VB 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
VB Code:
'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
thankx man .....
It really helped me a lot...
Thankx a lot again!