|
-
May 25th, 2005, 08:48 PM
#1
Thread Starter
Admodistrator
Find all Processes:
In a module:
VB Code:
Option Explicit
Public strstr As String
Const MAX_PATH& = 260
Declare Function ProcessFirst _
Lib "kernel32" Alias "Process32First" _
(ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Declare Function ProcessNext _
Lib "kernel32" Alias "Process32Next" _
(ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Declare Function CreateToolhelpSnapshot _
Lib "kernel32" Alias "CreateToolhelp32Snapshot" _
(ByVal lFlags As Long, _
lProcessID As Long) As Long
Declare Function CloseHandle _
Lib "kernel32" (ByVal hObject As Long) As Long
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
Form:
VB Code:
Private Sub Form_Load()
Call Getlist
End Sub
Private Function Getlist()
Const TH32CS_SNAPPROCESS As Long = 2&
Dim uProcess As PROCESSENTRY32
Dim rProcessFound As Long
Dim hSnapshot As Long
Dim szExename As String
Dim appCount As Integer
Dim I As Integer
uProcess.dwSize = Len(uProcess)
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
rProcessFound = ProcessFirst(hSnapshot, uProcess)
Do While rProcessFound
I = InStr(1, uProcess.szexeFile, Chr(0))
szExename = LCase$(Left$(uProcess.szexeFile, I - 1))
rProcessFound = ProcessNext(hSnapshot, uProcess)
List1.AddItem szExename'''szexename is each process name
Loop
End Function
enjoy it people
-
May 26th, 2005, 05:33 AM
#2
Re: Find all Processes:
Very nice, but I do have a question (which is probably picky).
Since you are not looking for a return value, I was wondering why GetList is a Function rather than a Sub?
-
May 26th, 2005, 06:19 AM
#3
Re: Find all Processes:
Nice code |2eM!x 
 Originally Posted by Hack
Very nice, but I do have a question (which is probably picky).
Since you are not looking for a return value, I was wondering why GetList is a Function rather than a Sub?
Does that really matter anyway?
Cheers,
RyanJ
-
May 26th, 2005, 07:48 AM
#4
Re: Find all Processes:
 Originally Posted by sciguyryan
Nice code |2eM!x
Does that really matter anyway?
Cheers,
RyanJ
In terms of functionality no...but it is contrary to my sense of consistency (Ok, ok...I know...I'm picky...what can I say? )
-
May 26th, 2005, 03:44 PM
#5
Thread Starter
Admodistrator
Re: Find all Processes:
guess nothing...but it looks cool : D
-
Jul 21st, 2005, 05:21 AM
#6
Hyperactive Member
Re: Find all Processes:
in your routine, is it possible to tell if a given process has a window? and if its a window, can i get its handle? without enumerating all the windows.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|