WMI Class Examples

The following examples show class definitions from the schema of a serial port driver. Note that the guid values shown in these examples are placeholders. Each class definition must have a unique GUID generated by guidgen.exe or uuidgen.exe (which are included in the Microsoft Windows SDK).


// Standard class for reporting serial port information
// Class qualifiers 
[WMI, guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"),
Dynamic, Provider("WMIProv"),
WmiExpense(1),
Locale("MS\\0x409"),
Description("Description of class"]
 
//Class name 
class Vendor_SerialInfo {
 
//Required items 
    [key, read] 
     string InstanceName;
    [read]
     boolean Active;
 
// Bytes sent on port
// Property qualifiers 
    [read,
     WmiDataId(1),
     WmiScale(0),
     WmiComplexity(1),
     WmiVolatility(1000)]
     Description("Description of property")]
// Data item 
     uint64 BytesSent;
 
// Bytes received on port
    [read,
     write,
     WmiDataId(2),
     WmiScale(0), 
     WmiVolatility(1000)]
     uint64 BytesReceived;
 
// Who owns the port 
    [read,
     WmiDataId(4),
     WmiScale(0),              
     WmiVolatility(60000)] 
    string Owner;
 
// Status bit array
    [read, write,
     WmiDataId(3),
     WmiScale(0)]
     byte Status[16];
 
//The number of items in the XmitBufferSize array
    [read,
     WmiDataId(5),
     WmiScale(0),
     WmiComplexity(1),
     WmiVolatility(1000)]
     uint32 XmitDescriptorCount;       
 
//Array of XmitDescriptor classes
    [read,
     WmiDataId(6),
     WmiSizeIs("XmitDescriptorCount"),
     WmiScale(0),
     WmiComplexity(1),
     WmiVolatility(1000)]
    Vendor_XmitDescriptor XmitBufferSize[];
}

The following is the class definition for the embedded class shown in the previous example. Note that this class does not contain InstanceName or Active items.


// Example of an embedded class 
[WMI, guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"),
class Vendor_XmitDescriptor {
    [read, WmiDataId(1)] int32 DestinationIndex;
    [read, WmiDataId(2)] int32 DestinationTarget;
}

The following is a class definition for an event block. The class is derived from WmiEvent.


// Example of an event
 [WMI, guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"),
 Dynamic, Provider("WMIProv"),
 locale("MS\\0x409"),
 Description("Serial Send Event"),
 WmiExpense(1)]
class Vendor_SerialSendEvent : WMIEvent
{
// Required items
    [key, read] 
      string InstanceName;
    [read]
      boolean Active;

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft