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.

51 lines
1.4 KiB

  1. #***************************************************************************
  2. # This script tests the setting of null property values
  3. # and null method parameters
  4. #***************************************************************************
  5. use OLE;
  6. use Win32;
  7. $locator = CreateObject OLE 'WbemScripting.SWbemLocator';
  8. # Note the next class uses "null" for a first argument
  9. $service = $locator->ConnectServer ($server, "root/default");
  10. $class = $service->Get ();
  11. # Set up a new class with an initialized property value
  12. $class->{Path_}->{Class} = "FredPerl";
  13. $class->{Properties_}->Add ("P", 3)->{Value} = 25;
  14. $class->Put_ ();
  15. # Now null the property value using non-dot access
  16. $class = $service->Get ("FredPerl");
  17. $property = $class->{Properties_}->Item("P");
  18. $property->{Value} = $value;
  19. $class->Put_ ();
  20. # Un-null
  21. $class = $service->Get ("FredPerl");
  22. $property = $class->{Properties_}->Item("P");
  23. $property->{Value} = 56;
  24. $class->Put_();
  25. # Now null it using dot access
  26. $class = $service->Get("FredPerl");
  27. $class->{P} = $value;
  28. $class->Put_();
  29. # Un-null
  30. $class = $service->Get ("FredPerl");
  31. $property = $class->{Properties_}->Item("P");
  32. $property->{Value} = 67;
  33. $class->Put_();
  34. # now null it using a variant
  35. use Win32::OLE::Variant;
  36. $var = Variant(VT_NULL, 0);
  37. $class = $service->Get("FredPerl");
  38. $class->{P} = $var;
  39. $class->Put_();