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.

115 lines
3.8 KiB

  1. '***************************************************************************
  2. 'This script tests the manipulation of property values, in the case that the
  3. 'property is an array type
  4. '***************************************************************************
  5. Set Service = GetObject("winmgmts:root/default")
  6. On Error Resume Next
  7. Set aClass = Service.Get()
  8. aClass.Path_.Class = "ARRAYPROP00"
  9. Set Property = aClass.Properties_.Add ("p1", 19, true)
  10. Property.Value = Array (12, 787, 34124)
  11. str = "The initial value of p1 is {"
  12. for x=LBound(aClass.Properties_("p1")) to UBound(aClass.Properties_("p1"))
  13. str = str & aClass.Properties_("p1")(x)
  14. if x <> UBound(aClass.Properties_("p1")) Then
  15. str = str & ", "
  16. End if
  17. next
  18. str = str & "}"
  19. WScript.Echo str
  20. '****************************************
  21. 'First pass of tests works on non-dot API
  22. '****************************************
  23. WScript.Echo ""
  24. WScript.Echo "PASS 1 - Use Non-Dot Notation"
  25. WScript.Echo ""
  26. 'Verify we can report the value of an element of the property value
  27. v = aClass.Properties_("p1")
  28. WScript.Echo "By indirection the first element of p1 had value:",v(0)
  29. 'Verify we can report the value directly
  30. WScript.Echo "By direct access the first element of p1 has value:", aClass.Properties_("p1")(0)
  31. 'Verify we can set the value of a single property value element
  32. aClass.Properties_("p1")(1) = 234
  33. WScript.Echo "After direct assignment the first element of p1 has value:", aClass.Properties_("p1")(1)
  34. 'Verify we can set the value of a single property value element
  35. Set v = aClass.Properties_("p1")
  36. v(1) = 345
  37. WScript.Echo "After indirect assignment the first element of p1 has value:", aClass.Properties_("p1")(1)
  38. 'Verify we can set the value of an entire property value
  39. aClass.Properties_("p1") = Array (5, 34, 178871)
  40. WScript.Echo "After direct array assignment the first element of p1 has value:", aClass.Properties_("p1")(1)
  41. str = "After direct assignment the entire value of p1 is {"
  42. for x=LBound(aClass.Properties_("p1")) to UBound(aClass.Properties_("p1"))
  43. str = str & aClass.Properties_("p1")(x)
  44. if x <> UBound(aClass.Properties_("p1")) Then
  45. str = str & ", "
  46. End if
  47. next
  48. str = str & "}"
  49. WScript.Echo str
  50. if Err <> 0 Then
  51. WScript.Echo Err.Description
  52. Err.Clear
  53. End if
  54. '****************************************
  55. 'Second pass of tests works on dot API
  56. '****************************************
  57. WScript.Echo ""
  58. WScript.Echo "PASS 2 - Use Dot Notation"
  59. WScript.Echo ""
  60. 'Verify we can report the array of a property using the dot notation
  61. str = "By direct access via the dot notation the entire value of p1 is {"
  62. for x=LBound(aClass.p1) to UBound(aClass.p1)
  63. str = str & aClass.p1(x)
  64. if x <> UBound(aClass.p1) Then
  65. str = str & ", "
  66. End if
  67. next
  68. str = str & "}"
  69. WScript.Echo str
  70. 'Verify we can report the value of a property array element using the "dot" notation
  71. WScript.Echo "By direct access the first element of p1 has value:", aClass.p1(0)
  72. 'Verify we can report the value of a property array element using the "dot" notation
  73. v = aClass.p1
  74. WScript.Echo "By indirect access the first element of p1 has value:", v(0)
  75. 'Verify we can set the value of a property array element using the "dot" notation
  76. WScript.Echo "By direct access the second element of p1 has been set to:", aClass.p1(2)
  77. aClass.p1(2) = 8889
  78. WScript.Echo "By direct access the second element of p1 has been set to:", aClass.p1(2)
  79. 'Verify we can set the entire array value using dot notation
  80. aClass.p1 = Array (412, 3, 544)
  81. str = "By direct access via the dot notation the entire value of p1 has been set to {"
  82. for x=LBound(aClass.p1) to UBound(aClass.p1)
  83. str = str & aClass.p1(x)
  84. if x <> UBound(aClass.p1) Then
  85. str = str & ", "
  86. End if
  87. next
  88. str = str & "}"
  89. WScript.Echo str
  90. 'Service.Put (aClass)
  91. if Err <> 0 Then
  92. WScript.Echo Err.Description
  93. Err.Clear
  94. End if