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.

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