Results 1 to 40 of 43

Thread: Enumerating Processes & much more! Update - Real Time Updating

Threaded View

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Enumerating Processes & much more! Update - Real Time Updating

    Looking over the Code Bank, I wasn't really able to find much on enumerating processes except for a WMI example. Since it seems like a lot of people are asking for such a thing, I decided to post an example I made up.

    The example I've added is like a mini task manager. Below, I'll show you have to enumerate a list of processes and then add them to a ListView. My example also shows you how to obtain a bunch of different information about the processes and how to close them out as well.

    There's a lot more features I'm going to add soon, so any suggestions, fixes, or code improvements are very much welcomed.

    Now, on to enumerating processes...

    There are a ton of different ways to go about this, so I'm just going to use the method I'm most familiar with.

    First, I declare an array of processes and assign that array all of the running processes:

    VB.NET Code:
    1. Dim Processes() As Process = System.Diagnostics.Process.GetProcesses

    Here I fully qualified the path with System.Diagnostics, but that isn't necessary if you've imported the namespace.

    Next, I'll loop through that list and retrieve the appropriate information. Since I'm adding the info to a ListView, I declare a variable to hold the ListViewItem and then I add the variable to the ListView at the end.

    VB.NET Code:
    1. For Each proc As Process In Processes
    2.      Dim lvi As New ListViewItem
    3.      lvi.Text = proc.ProcessName
    4.      lvi.SubItems.Add(proc.Id.ToString)
    5.      ListView1.Items.Add(lvi)
    6. Next proc

    And that's it! It's a super easy "process"

    You can download my Process Manager to get a better look at the code in action and see all of the information I've retrieved using the Process Class.

    I really hate code commenting and since I made this pretty quick, I didn't do much of that. So, if there are any questions, ask away

    My project obtains a ton of information about the processes such as: Name, PID, Memory Usage, Description, Modules, and much more!.

    If you just want to use it, all you have to do is build the project and run the created executable. You can use the code in any way you like. All I ask is that you don't re-package it and call it your own

    Process Manager:



    Latest Update: Version 1.7
    -Fixed an issue where you had to "re-click" the selected item in order to see a change in process priority
    -Added an icon
    -Added the ability to suspend and resume processes

    Process Manager 1.7 Download
    Attached Files Attached Files
    Last edited by weirddemon; Apr 18th, 2010 at 08:19 PM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

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