Sub perfCounterCategories()
[COLOR=darkgreen]'display categories in listbox1[/COLOR]
Dim pccs() As PerformanceCounterCategory = PerformanceCounterCategory.GetCategories()
Dim pccnames(pccs.Length - 1) As String
For i As Integer = 0 To pccs.Length - 1
pccnames(i) = pccs(i).CategoryName
Next
Array.Sort(pccnames)
ListBox1.DataSource = pccnames
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ListBox1.SelectedIndexChanged
[COLOR=darkgreen]'display instances in listbox2[/COLOR]
Dim pcc As New PerformanceCounterCategory(ListBox1.SelectedValue)
ListBox2.DataSource = pcc.GetInstanceNames
If ListBox2.Items.Count = 0 Then
[COLOR=darkgreen]'display counters in listbox3[/COLOR]
ListBox3.DataSource = pcc.GetCounters
ListBox3.DisplayMember = "CounterName"
End If
End Sub
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ListBox2.SelectedIndexChanged
[COLOR=darkgreen]'display counters in listbox3[/COLOR]
Dim pcc As New PerformanceCounterCategory(ListBox1.SelectedValue)
ListBox3.DataSource = pcc.GetCounters(ListBox2.SelectedValue)
ListBox3.DisplayMember = "CounterName"
End Sub