Registering an Event Provider

To create a WMI event provider you must register the __Win32Provider instance that represents your provider using an instance of __EventProviderRegistration. As a COM object, your provider must register with the operating system and WMI. The following procedure assumes that you have already implemented the registration process as described in Registering a Provider.

The following procedure describes how to register an event provider.

Aa393028.wedge(en-us,VS.85).gifTo register an event provider

  1. Create an instance of the __Win32Provider class that describes the provider.
  2. Create an instance of the __EventProviderRegistration class that describes the feature set of the provider.

    The __EventProviderRegistration class inherits many properties from the __ObjectProviderRegistration parent class. The properties local to the __EventProviderRegistration class are the object path to the provider and a list of queries that describe the events that the provider supports. For more information, see Querying WMI.

  3. Load your implementation of the __Win32Provider and __EventProviderRegistration classes into the WMI repository.

    WMI uses your class definition to register and access your event provider. For more information, see Registering a Provider.

The following code example describes an implementation of a __Win32Provider class and a __EventProviderRegistration class.

instance of __Win32Provider as $P
{
    ClientLoadableCLSID = NULL;
    CLSID = "{AA7828C5-95F9-11d2-BB0D-00C042424242}";
    DefaultMachineName = NULL;
    ImpersonationLevel = 0;
    InitializationReentrancy = 0;
    InitializeAsAdminFirst = FALSE;
    Name = "FaxEventProvider";
    PerLocaleInitialization = FALSE;
    PerUserInitialization = FALSE;
    Pure = TRUE;
    UnloadTimeout = NULL;
};

instance of __EventProviderRegistration
{  
Provider = $P;
EventQueryList = {
         "SELECT * FROM FaxEvent",
         "SELECT * FROM __InstanceCreationEvent WHERE TargetInstance ISA \"Win32_LogicalDisk\""};
};

The first query indicates that the provider generates all event notifications for the extrinsic event class FaxEvent. Because it uses the ISA operator, the second query implies that the provider generates notifications for all instance creation events for the Win32_LogicalDisk class and all of its subclasses.

When a provider registers to provide an intrinsic event, the event must apply to all instances of a class. In other words, a query cannot be written to provide instance creation events for only some of the disk drives that belong to the Win32_LogicalDisk class.

 

 

Show: