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.

277 lines
7.9 KiB

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  3. Begin VB.Form Form1
  4. Caption = "GetAs Tester"
  5. ClientHeight = 10350
  6. ClientLeft = 60
  7. ClientTop = 345
  8. ClientWidth = 13410
  9. LinkTopic = "Form1"
  10. ScaleHeight = 10350
  11. ScaleWidth = 13410
  12. StartUpPosition = 3 'Windows Default
  13. Begin VB.Frame ValueFrame
  14. Caption = "Values"
  15. Height = 8295
  16. Left = 7560
  17. TabIndex = 5
  18. Top = 1680
  19. Width = 5655
  20. Begin MSFlexGridLib.MSFlexGrid Values
  21. Height = 7575
  22. Left = 240
  23. TabIndex = 6
  24. Top = 360
  25. Width = 5175
  26. _ExtentX = 9128
  27. _ExtentY = 13361
  28. _Version = 393216
  29. Rows = 1
  30. FixedCols = 0
  31. GridColor = 255
  32. SelectionMode = 1
  33. AllowUserResizing= 1
  34. End
  35. End
  36. Begin MSFlexGridLib.MSFlexGrid PropList
  37. Height = 7575
  38. Left = 600
  39. TabIndex = 4
  40. Top = 2040
  41. Width = 6135
  42. _ExtentX = 10821
  43. _ExtentY = 13361
  44. _Version = 393216
  45. Rows = 1
  46. Cols = 4
  47. FixedCols = 0
  48. GridColor = 16384
  49. SelectionMode = 1
  50. AllowUserResizing= 1
  51. End
  52. Begin VB.CommandButton Go
  53. Caption = "Go"
  54. Default = -1 'True
  55. Height = 855
  56. Left = 7560
  57. TabIndex = 3
  58. Top = 600
  59. Width = 1455
  60. End
  61. Begin VB.Frame Properties
  62. Caption = "Properties"
  63. Height = 8295
  64. Left = 240
  65. TabIndex = 2
  66. Top = 1680
  67. Width = 6975
  68. End
  69. Begin VB.TextBox ObjectPath
  70. Height = 375
  71. Left = 480
  72. TabIndex = 0
  73. Text = "winmgmts:root\default:__cimomidentification=@"
  74. Top = 840
  75. Width = 6495
  76. End
  77. Begin VB.Frame Frame1
  78. Caption = "Object Path"
  79. Height = 975
  80. Left = 240
  81. TabIndex = 1
  82. Top = 480
  83. Width = 6975
  84. End
  85. End
  86. Attribute VB_Name = "Form1"
  87. Attribute VB_GlobalNameSpace = False
  88. Attribute VB_Creatable = False
  89. Attribute VB_PredeclaredId = True
  90. Attribute VB_Exposed = False
  91. Dim obj As SWbemObjectEx
  92. Private Sub Form_Load()
  93. PropList.ColWidth(0) = 2500
  94. PropList.ColWidth(1) = 2000
  95. PropList.ColWidth(2) = 1000
  96. PropList.ColWidth(3) = 550
  97. PropList.Row = 0
  98. PropList.Col = 0
  99. PropList.Text = "Property"
  100. PropList.Col = 1
  101. PropList.Text = "Type"
  102. PropList.Col = 2
  103. PropList.Text = "Array"
  104. PropList.Col = 3
  105. PropList.Text = "NULL"
  106. PropList.AddItem ""
  107. Values.ColWidth(0) = 2000
  108. Values.ColWidth(1) = 3100
  109. Values.Row = 0
  110. Values.Col = 0
  111. Values.Text = "Coercion Type"
  112. Values.Col = 1
  113. Values.Text = "Value"
  114. Values.AddItem ""
  115. End Sub
  116. Private Sub Go_Click()
  117. On Error GoTo ErrHandler:
  118. Dim prop As SWbemPropertyEx
  119. While PropList.Rows > 2
  120. PropList.RemoveItem (PropList.Rows - 1)
  121. Wend
  122. While Values.Rows > 2
  123. Values.RemoveItem (Values.Rows - 1)
  124. Wend
  125. ValueFrame.Caption = "Values"
  126. Set obj = GetObject(ObjectPath.Text)
  127. PropList.Row = 0
  128. For Each prop In obj.Properties_
  129. PropList.AddItem prop.Name & vbTab & CIMTypeToString(prop.cimType) & vbTab & prop.IsArray _
  130. & vbTab & IsNull(prop.value)
  131. Next
  132. Exit Sub
  133. ErrHandler:
  134. MsgBox Err.Description + ": 0x" + Hex(Err.Number), vbOKOnly, "Error"
  135. End Sub
  136. Public Function CIMTypeToString(cimType) As String
  137. Select Case cimType
  138. Case wbemCimtypeBoolean:
  139. CIMTypeToString = "wbemCimtypeBoolean"
  140. Case wbemCimtypeChar16:
  141. CIMTypeToString = "wbemCimtypeChar16"
  142. Case wbemCimtypeDatetime:
  143. CIMTypeToString = "wbemCimtypeDatetime"
  144. Case wbemCimtypeObject:
  145. CIMTypeToString = "wbemCimtypeObject"
  146. Case wbemCimtypeIllegal:
  147. CIMTypeToString = "wbemCimtypeIllegal"
  148. Case wbemCimtypeReal32:
  149. CIMTypeToString = "wbemCimtypeReal32"
  150. Case wbemCimtypeReal64:
  151. CIMTypeToString = "wbemCimtypeReal64"
  152. Case wbemCimtypeReference:
  153. CIMTypeToString = "wbemCimtypeReference"
  154. Case wbemCimtypeSint16:
  155. CIMTypeToString = "wbemCimtypeSint16"
  156. Case wbemCimtypeSint32:
  157. CIMTypeToString = "wbemCimtypeSint32"
  158. Case wbemCimtypeSint64:
  159. CIMTypeToString = "wbemCimtypeSint64"
  160. Case wbemCimtypeSint8:
  161. CIMTypeToString = "wbemCimtypeSint8"
  162. Case wbemCimtypeString:
  163. CIMTypeToString = "wbemCimtypeString"
  164. Case wbemCimtypeUint16:
  165. CIMTypeToString = "wbemCimtypeUint16"
  166. Case wbemCimtypeUint32:
  167. CIMTypeToString = "wbemCimtypeUint32"
  168. Case wbemCimtypeUint64:
  169. CIMTypeToString = "wbemCimtypeUint64"
  170. Case wbemCimtypeUint8:
  171. CIMTypeToString = "wbemCimtypeUint8"
  172. Case wbemCimtypeIUnknown:
  173. CIMTypeToString = "wbemCimtypeIUnknown"
  174. End Select
  175. End Function
  176. Private Sub PropList_Click()
  177. Dim propertyName As String
  178. If PropList.Row > 1 Then
  179. propertyName = PropList.Text
  180. If Len(propertyName) > 0 Then
  181. ValueFrame.Caption = "Values for " & propertyName
  182. While Values.Rows > 2
  183. Values.RemoveItem (Values.Rows - 1)
  184. Wend
  185. ' Now do the coercion of the value
  186. Dim property As SWbemPropertyEx
  187. Set property = obj.Properties_(propertyName)
  188. GetAs property, wbemCimtypeBoolean
  189. GetAs property, wbemCimtypeChar16
  190. GetAs property, wbemCimtypeDatetime
  191. GetAs property, wbemCimtypeObject
  192. GetAs property, wbemCimtypeIllegal
  193. GetAs property, wbemCimtypeReal32
  194. GetAs property, wbemCimtypeReal64
  195. GetAs property, wbemCimtypeReference
  196. GetAs property, wbemCimtypeSint16
  197. GetAs property, wbemCimtypeSint32
  198. GetAs property, wbemCimtypeSint64
  199. GetAs property, wbemCimtypeSint8
  200. GetAs property, wbemCimtypeString
  201. GetAs property, wbemCimtypeUint16
  202. GetAs property, wbemCimtypeUint32
  203. GetAs property, wbemCimtypeUint64
  204. GetAs property, wbemCimtypeUint8
  205. GetAs property, wbemCimtypeIUnknown
  206. End If
  207. End If
  208. End Sub
  209. Private Sub GetAs(property, cimType)
  210. On Error Resume Next
  211. Dim value
  212. Err.Clear
  213. If (cimType <> wbemCimtypeObject) And (cimType <> wbemCimtypeIUnknown) Then
  214. value = property.GetAs(cimType)
  215. Else
  216. Set value = property.GetAs(cimType)
  217. End If
  218. If Err <> 0 Then
  219. Values.AddItem CIMTypeToString(cimType) & vbTab & Err.Description
  220. Else
  221. If (cimType <> wbemCimtypeObject) And (cimType <> wbemCimtypeIUnknown) Then
  222. Values.AddItem CIMTypeToString(cimType) & vbTab & value
  223. Else
  224. Values.AddItem CIMTypeToString(cimType) & vbTab & "<object>"
  225. End If
  226. End If
  227. Exit Sub
  228. End Sub
  229. Private Sub PropList_RowColChange()
  230. PropList_Click
  231. End Sub