|
-
May 16th, 2003, 10:20 AM
#1
Thread Starter
Hyperactive Member
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
Last edited by DaveBo; May 16th, 2003 at 10:23 AM.
"The wise man doesn't know all the answers, but he knows where to find them."
VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15
-
May 16th, 2003, 12:35 PM
#2
Don't "System Idle Process" and "System" show up as null?
I don't think you would want to remove them.
Check out my last two posts in this thread.
You may want to get the executable name first before you start terminating processes.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|