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.

92 lines
2.4 KiB

  1. VERSION 5.00
  2. Begin VB.Form Form1
  3. Caption = "Form1"
  4. ClientHeight = 3195
  5. ClientLeft = 60
  6. ClientTop = 345
  7. ClientWidth = 4680
  8. LinkTopic = "Form1"
  9. ScaleHeight = 3195
  10. ScaleWidth = 4680
  11. StartUpPosition = 3 'Windows Default
  12. End
  13. Attribute VB_Name = "Form1"
  14. Attribute VB_GlobalNameSpace = False
  15. Attribute VB_Creatable = False
  16. Attribute VB_PredeclaredId = True
  17. Attribute VB_Exposed = False
  18. Private Sub Form_Load()
  19. On Error Resume Next
  20. 'Ask for non-existant class to force error from CIMOM
  21. Dim t_Service As SWbemServices
  22. Dim t_Object As SWbemObject
  23. Set t_Service = GetObject("winmgmts://./root/default")
  24. Set t_Object = t_Service.Get("Nosuchclass000")
  25. If Err = 0 Then
  26. Debug.Print "Got a class"
  27. Else
  28. PrintErrorInfo
  29. Set t_Object2 = CreateObject("WbemScripting.SWbemLastError")
  30. If Err <> 0 Then
  31. Debug.Print "Couldn't get last error again - as expected"
  32. Err.Clear
  33. Else
  34. Debug.Print "Got the error object again - this shouldn't have happened!"
  35. End If
  36. 'Force the error again
  37. Set t_Object = t_Service.Get("Nosuchclass000")
  38. If Err <> 0 Then
  39. PrintErrorInfo
  40. Err.Clear
  41. Else
  42. Debug.Print "Got a class"
  43. End If
  44. End If
  45. End Sub
  46. Sub PrintErrorInfo()
  47. Debug.Print ""
  48. Dim errObj As SWbemLastError
  49. Debug.Print "Err Information:"
  50. Debug.Print ""
  51. Debug.Print " Source:", Err.Source
  52. Debug.Print " Description:", Err.Description
  53. Debug.Print " Number", Err.Number
  54. Debug.Print " LastDllError", Err.LastDllError
  55. 'Create the last error object
  56. Set errObj = CreateObject("WbemScripting.SWbemLastError")
  57. Debug.Print ""
  58. Debug.Print "WBEM Last Error Information:"
  59. Debug.Print ""
  60. Debug.Print " Operation:", errObj.Operation
  61. Debug.Print " Provider:", errObj.ProviderName
  62. strDescr = errObj.Description
  63. strPInfo = errObj.ParameterInfo
  64. strCode = errObj.StatusCode
  65. If Not IsNull(strDescr) Then
  66. Debug.Print " Description:", strDescr
  67. End If
  68. If Not IsNull(strPInfo) Then
  69. Debug.Print " Parameter Info:", strPInfo
  70. End If
  71. If Not IsNull(strCode) Then
  72. Debug.Print " Status:", strCode
  73. End If
  74. Err.Clear
  75. Set errObj = Nothing
  76. Debug.Print ""
  77. End Sub