You can easily get information on running processes through some methods from the Process
class that provide the ability of getting process instances. For example, GetProcesses
returns an array of Process
objects, each one representing a running process whereas GetProcessById
and GetProcessByName
return information on the specified process given the identification number or name, whereas GetCurrentProcess
returns an instance of the Process
class representing the current process. Then the Process
class exposes lots of useful properties for retrieving information, each of them self-explanatory such as ProcessName
, Id
, ExitCode
, Handle
, or HasExited
but also other advanced information properties, such as PageMemorySize
or VirtualMemorySize
, which respectively return the memory size associated with the process on the page memory or the virtual memory. The Visual Studio’s Object Browser and IntelliSense can help you with the rest of available properties. At the moment focus on how you can get information on running processes. The coolest way for getting process information is using LINQ to Objects. The following query, and subsequent For..Each
loop, demonstrates how to retrieve a list of names of running processes:
Notice that the query result is converted into IEnumerable(Of String)
so that you can eventually bind the list to a user interface control supporting the type.
3.138.170.174