Retrieving information on system resources and process information was not possible wihtout API calls in VB6. Calling API functions has its own difficulties. Identifying correct datatypes, Identifying the API functions, having ErrorHandles to avoid app Crashes are some of those..
VB.NET relieves us from all such problems by providing class libraries to access system resources and environment information. Here is a simple example In VB.NET, that depicts the method to get the list of of processes that are currently running in your system.
1) Place a button in the form
2) Place a TextBox in the Form and name it as txtProcesses
3) Set the Multi-line property of the TextBox(txtProcesses) to True
4) Import the System namespace
5) Write the following code in the CommandButton click Event
Dim sProcesses() As System.Diagnostics.Process
Dim sProcess As System.Diagnostics.Process
Dim s As String
On Error Goto ErrorHandler
sProcesses = System.Diagnostics.Process.GetProcesses()
s = ""
s = vbCrLf & "ProCSS Info " & vbCrLf
For Each sProcess In sProcesses
s = s & sProcess.Id & Space(5) & sProcess.ProcessName() & vbCrLf
Next
txtProcesses.Text = s
ErrorHandler:
MsgBox "Unexpected Error occurred"
System.Diagnostics.Process is NameSpace provides the method GetProcesses() to get the list of process running in your system. This function returns Object array of type Process. The ID and ProcessName properties of the Process object can be used to retrive the ProcessID(PID) and the Name process.
The overloaded function GetProcesses with << System Name >> parameter can be invoked to get list of processes running in a remote system.
Happy programming with VB.NET.