Link to home
Start Free TrialLog in
Avatar of mrpatil
mrpatil

asked on

how to get all information of task manager using vb.net

i want to obtain the total physical memory and available physical memory
which is display on task manager in performance tab and the list of process with memory usage which is currently running on the task manager in process tab in vb.net application


Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

To retrieve the process-information, you need something like this:
Dim poc() as process = process.getprocesses()
for i as integer = 0 to poc.length - 1
if poc(i).processname.tostring <> "system" or poc(i).processname.tostring <> "idle" then
try
lstview.items.add(environment.machinename)
lstview.items(i).subitems.add(poc(i).processname)
lstview.items(i).subitems.add(poc(i).mainmodule.filename)
lstview.items(i).subitems.add(poc(i).mainwindowtitle)
catch ex as exception
msgbox(poc(i).processname.tostring & " " & ex.message)
end try
end if
next 

Open in new window

Avatar of mrpatil
mrpatil

ASKER

this code not give the specific running process list and available and total physical memory
Memory usage
------------------

Dim p As Process
For Each p In p.GetProcesses
  lblMemUsage.Text = p.ToString.Remove(0, 27).ToLower & " " & (p.WorkingSet / 1024).ToString("0,000") & " K"
Next
VB.Net: Getting memoryusage of one process
http://wiki.lessthandot.com/index.php/VB.Net:_Getting_memoryusage_of_one_process
Public Shared Function GetMemoryUsage(ByVal ProcessName As String) As String 
            Dim _Process As Process = Nothing 
            Dim _Return As String = "" 
            For Each _Process In Process.GetProcessesByName(ProcessName) 
                If _Process.ToString.Remove(0, 27).ToLower = "(" & ProcessName.ToLower & ")" Then 
                    _Return = (_Process.WorkingSet64 / 1024).ToString("0,000") & " K" 
                End If 
            Next 
            If Not _Process Is Nothing Then 
                _Process.Dispose() 
                _Process = Nothing 
            End If 
            Return _Return 
        End Function

Open in new window

Avatar of mrpatil

ASKER

this code not give available physical size & total physical size(i.e. display on the task manager in performance tab)
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrpatil

ASKER

now please give the list of process which are running in the task manager with name of process and use of cpu and memory