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.

78 lines
2.2 KiB

  1. Attribute VB_Name = "Globals"
  2. Option Explicit
  3. Public Modules As New Collection
  4. Public Tests As New Collection
  5. Public Sub ClearTests()
  6. Dim i As Integer
  7. For i = 0 To Tests.count - 1
  8. Tests.Remove 1
  9. Next i
  10. End Sub
  11. 'Public Function CheckError(errcode As Long, n As Node, shortdesc As String) As Boolean
  12. ' CheckError = False
  13. ' If errcode <> WBEM_NO_ERROR Then
  14. ' 'MsgBox "Error " & Hex(Err.Number) & " Occured in " & n.FullPath & " while " & shortdesc
  15. '
  16. ' Dim errobj As Object
  17. ' Dim s As String
  18. ' Set errobj = Nothing
  19. ' Set errobj = CreateObject("WBEMIDispatchLastError")
  20. '
  21. ' errobj.GetObjectText 0, s
  22. '
  23. ' n.Tag = n.Tag & vbCrLf
  24. '
  25. ' If Not InStr(1, s, "i") > 0 Then
  26. ' n.Tag = n.Tag & "Errorcode: " & Hex(errcode) & vbCrLf & _
  27. ' "Occured while:" & vbCrLf & shortdesc
  28. ' Else
  29. ' n.Tag = n.Tag & "SCODE: " & Hex(errcode) & " [" & shortdesc & "]" & vbCrLf
  30. ' n.Tag = n.Tag & ObjText2Text(s)
  31. ' End If
  32. '
  33. ' CheckError = True
  34. ' End If
  35. 'End Function
  36. Public Function CheckError(errcode As Long, n As Node, shortdesc As String) As Boolean
  37. CheckError = False
  38. If errcode <> WBEM_NO_ERROR Then
  39. Dim errobj As New SWbemLastError
  40. Dim s As String
  41. s = Err.Description
  42. If s = "" Then
  43. n.Tag = n.Tag & "Errorcode: " & Hex(errcode) & vbCrLf & _
  44. "Occured while: " & shortdesc & vbCrLf & _
  45. "Error Message: {blank}"
  46. Else
  47. n.Tag = n.Tag & "SCODE: " & Hex(errcode) & " [" & shortdesc & "]" & vbCrLf
  48. n.Tag = n.Tag & s
  49. End If
  50. CheckError = True
  51. End If
  52. End Function
  53. Public Function ObjText2Text(sText As String) As String
  54. 'we need to walk through and clean up all the lf's
  55. Dim i As Integer
  56. Dim o As String
  57. For i = 1 To Len(sText)
  58. If Mid(sText, i, 1) = Chr(10) Then
  59. o = o & vbCrLf
  60. Else
  61. o = o & Mid(sText, i, 1)
  62. End If
  63. Next i
  64. ObjText2Text = o
  65. End Function