Results 1 to 2 of 2

Thread: Show, expose, unhide all tasks/jobs/processes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Question 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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width