/////////////////////////////////////////////////////////////////////// // // VP_SAMPLE1.MOF // // Purpose: Sample view provider MOF for union views // // Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved // /////////////////////////////////////////////////////////////////////// #pragma namespace("\\\\.\\root") instance of __namespace { Name = "sample_views"; }; #pragma namespace("\\\\.\\root\\sample_views") //********************************************************************************************************* // // The following three instances register the view provider in the current namespace // //********************************************************************************************************* instance of __Win32Provider as $DataProv { Name = "MS_VIEW_INSTANCE_PROVIDER"; ClsId = "{AA70DDF4-E11C-11D1-ABB0-00C04FD9159E}"; ImpersonationLevel = 1; PerUserInitialization = "True"; }; instance of __InstanceProviderRegistration { Provider = $DataProv; SupportsPut = True; SupportsGet = True; SupportsDelete = True; SupportsEnumeration = True; QuerySupportLevels = {"WQL:UnarySelect"}; }; instance of __MethodProviderRegistration { Provider = $DataProv; }; //********************************************************************************************************* // // The following classes demonstrate unions of classes defined in multiple namespaces // // In these cases, a source system property is added as a key to maintain uniqueness. // //********************************************************************************************************* // UNION CASE1 // In this case, the namespaces are on different machines (supported on Win2000 only). //====================================================================================== [union, ViewSources {"Select * from Win32_OperatingSystem"}, ViewSpaces {"\\\\.\\root\\cimv2::\\\\MACHINE1\\root\\cimv2"}, dynamic, provider("MS_VIEW_INSTANCE_PROVIDER") ] class Union_OS { [key, PropertySources{"Name"}] string Name; [key, PropertySources{"__Server"}] string Server; [PropertySources{"Version"}] string Version; [PropertySources{"BuildNumber"}] string BuildNumber; }; // UNION CASE2 // In this case, the namespaces are on the same machine (supported on all platforms). //===================================================================================== [union, ViewSources {"Select * from __Win32Provider"}, ViewSpaces {"\\\\.\\root\\cimv2::\\\\.\\root\\wmi::\\\\.\\root\\snmp\\localhost::\\\\.\\root\\directory\\ldap"}, dynamic, provider("MS_VIEW_INSTANCE_PROVIDER") ] class Union_ProvidersOnThisMachine { [key, PropertySources{"Name"}] string Name; [key, PropertySources{"__Namespace"}] string Location; [PropertySources{"CLSID"}] string ClassIdentifier; [PropertySources{"PerUserInitialization"}] boolean PerUserInitialization; }; //********************************************************************************************************* // // The following classes demonstrate unions of similar classes. The source classes must // have the same key structure. // //********************************************************************************************************* // UNION CASE3 // In this case, the namespaces are on the same machine (supported on all platforms). // This class lists several types of drives supported by the Win32 Provider. //===================================================================================== [ union, ViewSources { "Select * from Win32_DiskDrive", "Select * from Win32_CDRomDrive", "Select * from Win32_FloppyDrive" }, ViewSpaces { "\\\\.\\root\\cimv2", "\\\\.\\root\\cimv2", "\\\\.\\root\\cimv2" }, dynamic, provider("MS_VIEW_INSTANCE_PROVIDER") ] class Union_PhysicalDrives { [key, PropertySources{"DeviceId", "DeviceId", "DeviceId"}] string DeviceIdentifier; [PropertySources{"MediaType", "MediaType", "Caption"}] string Type; [PropertySources{"Partitions", "", ""}] uint32 NumberOfPartitions; [PropertySources{"", "MediaLoaded", ""}] boolean DiscLoaded; [PropertySources{"Caption", "Name", "Name"}] string Name; }; // UNION CASE4 // In this case, remote namespaces are used too (supported on Win2000). // This class lists several types of drives supported by the Win32 Provider on the // local machine and a machine named Machine1 //===================================================================================== [ union, ViewSources { "Select * from Win32_DiskDrive", "Select * from Win32_CDRomDrive", "Select * from Win32_FloppyDrive" }, ViewSpaces { "\\\\.\\root\\cimv2::\\\\Machine1\\root\\cimv2", "\\\\.\\root\\cimv2::\\\\Machine1\\root\\cimv2", "\\\\.\\root\\cimv2::\\\\Machine1\\root\\cimv2" }, dynamic, provider("MS_VIEW_INSTANCE_PROVIDER") ] class Union_PhysicalDrivesOnMyMachines { [key, PropertySources{"DeviceId", "DeviceId", "DeviceId"}] string DeviceIdentifier; [PropertySources{"MediaType", "MediaType", "Caption"}] string Type; [PropertySources{"Partitions", "", ""}] uint32 NumberOfPartitions; [PropertySources{"", "MediaLoaded", ""}] boolean DiscLoaded; [PropertySources{"Caption", "Name", "Name"}] string Name; }; // UNION CASE 5 // Methods are only supported on Union views. // Furthermore, the signature of the method has to match that // of the source exactly. The easiest way of ensuring this is // to copy the method signature (from the MOF or by extracting // it from the database using wbemtest) and pasting it into the // view class. [ Union, ViewSources {"Select * From Win32_OperatingSystem"}, ViewSpaces {"\\\\.\\root\\cimv2"}, dynamic, provider("MS_VIEW_INSTANCE_PROVIDER") ] class Union_OSWithMethods { [key, PropertySources{"Name"}] string Name; [key, PropertySources{"__Server"}] string Server; [PropertySources{"Version"}] string Version; [PropertySources{"BuildNumber"}] string BuildNumber; //Methods [implemented, MethodSource{"Reboot"} ] uint32 Reboot(); [implemented, Privileges{"SeShutdownPrivilege"}, MethodSource{"Shutdown"} ] uint32 Shutdown(); [implemented: ToSubClass, Privileges{"SeShutdownPrivilege"}: ToSubClass, MappingStrings{"Win32API|System Shutdown Functions|ExitWindowsEx"}: ToSubClass, MethodSource{"Win32Shutdown"} ] uint32 Win32Shutdown([in, MappingStrings{"Win32API|System Shutdown Functions|ExitWindowsEx"}: ToSubClass, BitMap{"0x00000000", "0x00000001", "0x00000002", "0x00000004", "0x00000008"}: ToSubClass] sint32 Flags, [in, MappingStrings{"Win32API|System Shutdown Functions|ExitWindowsEx"}: ToSubClass] sint32 Reserved = 0); };