Show, expose, unhide all tasks/jobs/processes
I don't know about you, but I get very upset every time I find another uninvited program running on my PC.
I'm writing a little app to save 'snapshots' of the tasks/processes currently running on my system and then, later, compare them with what's currently running so I can quickly see if there's anything new going on.
My question is: how can I be sure I'm seeing EVERYTHING that's running?
I've seen a lot of effort here to hide tasks, using TaskVisible and APIs etc. If something like that is running on my PC I want to know.
Below is the code I'm using to list apps right now (from this site I'm sure)
Will this do it? Are there holes or 'opportunities' to improve on this?
Thanks, DaveBo
Code:
Private Const TH32CS_SNAPPROCESS As Long = 2&
Private Const MAX_PATH As Integer = 260
Private 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
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" _
Alias "CreateToolhelp32Snapshot" _
(ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" _
(ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" _
(ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Public Sub Show_All_Processes()
Dim hSnapshot As Long
Dim uProcess As PROCESSENTRY32
Dim r As Long
Dim strTmp As String
Dim FirstNull As Integer
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapshot = 0 Then Exit Sub
uProcess.dwSize = Len(uProcess)
r = ProcessFirst(hSnapshot, uProcess)
Do While r
' Find 1st NULL and remove it and everything following it
strTmp = uProcess.szexeFile
FirstNull = InStr(strTmp, Chr(0))
strTmp = Left$(strTmp, FirstNull - 1)
Debug.Print strTmp
r = ProcessNext(hSnapshot, uProcess)
Loop
Call CloseHandle(hSnapshot)
End Sub