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.

69 lines
2.0 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. '***************************************************************************
  20. 'This script tests the setting of null property values and passing of
  21. 'null values to methods
  22. '***************************************************************************
  23. On Error Resume Next
  24. Dim Locator As SWbemLocator
  25. Dim Service As SWbemServices
  26. Dim Class As SWbemObject
  27. Dim Property As SWbemProperty
  28. Dim Value As Variant
  29. 'Value = Null
  30. Set Locator = CreateObject("WbemScripting.SWbemLocator")
  31. 'Note next call uses an unitialized Variant as an
  32. 'an argument.
  33. ' Full mappings are:
  34. ' 1) Unitialized Variant variable VT_VARIANT|VT_BYREF (VT_EMPTY)
  35. ' 2) Variant variable value = null VT_VARIANT|VT_BYREF (VT_NULL)
  36. ' 3) null constant VT_NULL
  37. ' 4) omitted parameter VT_EMPTY (DISP_E_PARAMNOTFOUND)
  38. Set Service = Locator.ConnectServer(Value, "root/default")
  39. Set Class = Service.Get
  40. 'Set up a new class with an initialized property value
  41. Class.Path_.Class = "Fred"
  42. Class.Properties_.Add("P", 3).Value = 25
  43. Class.Put_
  44. 'Now null the property value using non-dot access
  45. Set Class = Service.Get("Fred")
  46. Set Property = Class.Properties_("P")
  47. Property.Value = Null
  48. Class.Put_
  49. 'Un-null
  50. Set Class = Service.Get("Fred")
  51. Set Property = Class.Properties_("P")
  52. Property.Value = 56
  53. Class.Put_
  54. 'Now null it using dot access
  55. Set Class = Service.Get("Fred")
  56. Class.P = Null
  57. Class.Put_
  58. If Err <> 0 Then
  59. Debug.Print Err.Description, Err.Source, Err.Number
  60. Err.Clear
  61. End If
  62. End Sub