Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

237 lines
7.0 KiB

  1. VERSION 5.00
  2. Begin VB.Form Form1
  3. Caption = "Form1"
  4. ClientHeight = 12615
  5. ClientLeft = 60
  6. ClientTop = 345
  7. ClientWidth = 9795
  8. LinkTopic = "Form1"
  9. ScaleHeight = 12615
  10. ScaleWidth = 9795
  11. StartUpPosition = 3 'Windows Default
  12. Begin VB.Frame Frame4
  13. Caption = "Object Detail"
  14. Height = 3135
  15. Left = 360
  16. TabIndex = 11
  17. Top = 8880
  18. Width = 8775
  19. Begin VB.ListBox ObjectDetail
  20. Height = 2400
  21. Left = 360
  22. TabIndex = 12
  23. Top = 360
  24. Width = 7935
  25. End
  26. End
  27. Begin VB.Frame Instances
  28. Caption = "Instances"
  29. Height = 3735
  30. Left = 360
  31. TabIndex = 9
  32. Top = 4800
  33. Width = 8775
  34. Begin VB.ListBox PerfInstanceNames
  35. Height = 2985
  36. Left = 240
  37. TabIndex = 10
  38. Top = 360
  39. Width = 8295
  40. End
  41. End
  42. Begin VB.CommandButton Refresh
  43. Caption = "Refresh Now"
  44. BeginProperty Font
  45. Name = "Verdana"
  46. Size = 8.25
  47. Charset = 0
  48. Weight = 700
  49. Underline = 0 'False
  50. Italic = 0 'False
  51. Strikethrough = 0 'False
  52. EndProperty
  53. Height = 855
  54. Left = 120
  55. TabIndex = 8
  56. Top = 3720
  57. Width = 3255
  58. End
  59. Begin VB.ListBox PerfList
  60. Height = 2985
  61. Left = 4440
  62. TabIndex = 6
  63. Top = 720
  64. Width = 4095
  65. End
  66. Begin VB.CommandButton DispPerf
  67. Caption = "Display Peformance Counters"
  68. BeginProperty Font
  69. Name = "Verdana"
  70. Size = 8.25
  71. Charset = 0
  72. Weight = 700
  73. Underline = 0 'False
  74. Italic = 0 'False
  75. Strikethrough = 0 'False
  76. EndProperty
  77. Height = 855
  78. Left = 120
  79. TabIndex = 5
  80. Top = 2640
  81. Width = 3255
  82. End
  83. Begin VB.Frame Frame2
  84. Caption = "Namespace"
  85. Height = 855
  86. Left = 120
  87. TabIndex = 3
  88. Top = 1320
  89. Width = 2655
  90. Begin VB.TextBox Namespace
  91. Height = 375
  92. Left = 240
  93. TabIndex = 4
  94. Text = "root\cimv2"
  95. Top = 360
  96. Width = 2295
  97. End
  98. End
  99. Begin VB.TextBox Text2
  100. Height = 495
  101. Left = 240
  102. TabIndex = 1
  103. Text = "Text2"
  104. Top = 1440
  105. Width = 2295
  106. End
  107. Begin VB.Frame Frame3
  108. Caption = "Available Performance Counters"
  109. Height = 3855
  110. Left = 3960
  111. TabIndex = 7
  112. Top = 240
  113. Width = 5175
  114. End
  115. Begin VB.TextBox Server
  116. Height = 375
  117. Left = 360
  118. TabIndex = 0
  119. Text = "alanbos5"
  120. Top = 600
  121. Width = 2295
  122. End
  123. Begin VB.Frame Frame1
  124. Caption = "Server"
  125. Height = 855
  126. Left = 120
  127. TabIndex = 2
  128. Top = 240
  129. Width = 2655
  130. End
  131. End
  132. Attribute VB_Name = "Form1"
  133. Attribute VB_GlobalNameSpace = False
  134. Attribute VB_Creatable = False
  135. Attribute VB_PredeclaredId = True
  136. Attribute VB_Exposed = False
  137. Dim locator As SWbemLocator
  138. Dim service As SWbemServices
  139. Dim refresher As SWbemRefresher
  140. Dim instancesIndex As Integer
  141. Private Sub DispPerf_Click()
  142. On Error Resume Next
  143. Set service = locator.ConnectServer(Server.Text, Namespace.Text)
  144. If Err <> 0 Then
  145. MsgBox "Could not connect to namespace"
  146. Else
  147. Dim classes As SWbemObjectSet
  148. Set classes = service.SubclassesOf("Win32_PerfRawData")
  149. Dim wmiClass As SWbemObject
  150. For Each wmiClass In classes
  151. If ("Win32_PerfRawData" <> wmiClass.Path_.Class) Then
  152. PerfList.AddItem (wmiClass.Path_.Class)
  153. End If
  154. Next
  155. End If
  156. End Sub
  157. Private Sub Form_Load()
  158. Set locator = CreateObject("WbemScripting.SWbemLocator")
  159. Set refresher = CreateObject("WbemScripting.SWbemRefresher")
  160. End Sub
  161. Private Sub PerfInstanceNames_Click()
  162. RefreshObjectDetail (PerfInstanceNames)
  163. End Sub
  164. Private Sub PerfList_Click()
  165. Dim selectedClass As String
  166. selectedClass = PerfList
  167. Instances.Caption = "Instances of " & selectedClass
  168. ' Remove any previous refreshable items
  169. refresher.DeleteAll
  170. ' Add the enumeration to our refresher
  171. instancesIndex = refresher.AddEnum(service, selectedClass).Index
  172. ' Do a refresh
  173. Refresh_Click
  174. End Sub
  175. Private Function RefreshObjectDetail(objectName As String)
  176. Dim selectedInstances As SWbemObjectSet
  177. Set selectedInstances = refresher(instancesIndex).ObjectSet
  178. ObjectDetail.Clear
  179. Dim selectedInstance As SWbemObject
  180. Set selectedInstance = selectedInstances(objectName)
  181. Dim property As SWbemProperty
  182. For Each property In selectedInstance.Properties_
  183. ObjectDetail.AddItem (property.Name & ": " & property.Value)
  184. Next
  185. End Function
  186. Private Sub Refresh_Click()
  187. refresher.Refresh
  188. Dim selectedInstances As SWbemObjectSet
  189. Set selectedInstances = refresher(instancesIndex).ObjectSet
  190. 'Remember what was selected
  191. Dim lastSelection As String
  192. lastSelection = PerfInstanceNames
  193. PerfInstanceNames.Clear
  194. Dim perfInstance As SWbemObject
  195. Dim foundSameItem As Boolean
  196. foundSameItem = False
  197. For Each perfInstance In selectedInstances
  198. PerfInstanceNames.AddItem (perfInstance.Path_.Path)
  199. If (lastSelection = perfInstance.Path_.Path) Then
  200. ' Found it again!
  201. PerfInstanceNames.Selected(PerfInstanceNames.ListCount - 1) = True
  202. foundSameItem = True
  203. 'Refresh the detail too
  204. RefreshObjectDetail (PerfInstanceNames)
  205. End If
  206. Next
  207. If (foundSameItem = False) Then
  208. If (PerfInstanceNames.ListCount > 0) Then
  209. PerfInstanceNames.Selected(0) = True
  210. RefreshObjectDetail (PerfInstanceNames)
  211. Else
  212. ObjectDetail.Clear
  213. End If
  214. End If
  215. End Sub