Imports System.Diagnostics
Imports System.Collections
Public Class Processes
Private Sub Processes_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Process As New Process()
Dim Count As Integer = 0
ListView1.Items.Clear()
For Each Process In Process.GetProcesses(Main.txtHostName.Text)
On Error Resume Next
ListView1.Items.Add(Process.ProcessName)
ListView1.Items(Count).SubItems.Add(FormatNumber(Math.Round(Process.PrivateMemorySize64 / 1024), 0))
ListView1.Items(Count).SubItems.Add(Process.Id)
ListView1.Items(Count).SubItems.Add(ProductName)
'ListView1.Items(Count).SubItems.Add(Process.Id)
Count += 1
AddHandler Me.ListView1.ColumnClick, AddressOf ColumnClick
Next
ToolStripStatusLabel1.Text = "Processes: " & ListView1.Items.Count
End Sub
'Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
' For Each Process As ListViewItem In ListView1.SelectedItems
' System.Diagnostics.Process.GetProcessById(Process.SubItems(3).Text).Kill()
' Next
' Processes_Load(Nothing, Nothing)
'End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Processes_Load(Nothing, Nothing)
End Sub
' ColumnClick event handler.
Private Sub ColumnClick(ByVal o As Object, ByVal e As ColumnClickEventArgs)
' Set the ListViewItemSorter property to a new ListViewItemComparer
' object. Setting this property immediately sorts the
' ListView using the ListViewItemComparer object.
'Change this based on which direction you want
Dim blnAscending As Boolean = True
Me.listView1.ListViewItemSorter = New ListViewItemComparer(e.Column, blnAscending)
End Sub
' Implements the manual sorting of items by columns.
Class ListViewItemComparer
Implements IComparer
Private col As Integer
Private AscOrder As Boolean
Public Sub New()
col = 0
AscOrder = True
End Sub
Public Sub New(ByVal column As Integer, ByVal Ascending As Boolean)
col = column
AscOrder = Ascending
End Sub
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _
Implements IComparer.Compare
If AscOrder Then
Return [String].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text)
Else
Return [String].Compare(CType(y, ListViewItem).SubItems(col).Text, CType(x, ListViewItem).SubItems(col).Text)
End If
End Function
End Class
End Class
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE