4.1 Creating an Event Class

Creating an event class

Figure 1: Creating an event class

The previous figure shows the sequence for a client publisher application that is creating an event on the server. It assumes that the client already knows that the type library ID for the EventClass is 3BFF4039-03C2-410f-B6A6-F4EBC250C2CC.

To set up an event class:

  1. The client application starts by performing a DCOM activation for the event class object on the server by using the class ID CLSID_EventClass.

  2. The client application dynamically generates a UUID (in this example, DF01D194-D694-41e5-BA79-8DEDE00ED0EA) according to [C706] section A.2.5. It converts the UUID to a string using the format that is specified in section 2.2.3. Using the string, the client calls put_EventClassID on the event class object to set the EventClassID property.

       [in] BSTR bstrEventClassID ="{DF01D194-D694-41e5-BA79-8DEDE00ED0EA}"
  3. The server stores the EventClassID and returns S_OK.

  4. It then sets the Typelib property of the event class by calling the put_TypeLib method.

       [in] BSTR bstrTypeLib ="TypelibFileName.tlb"
  5. The server stores the TypeLib property and returns S_OK.

  6. The client chooses a human-readable name for the event class (in this example, "TestEventClass"). It then uses this name to set the EventClassName property by calling the put_EventClassName method.

       [in] BSTR bstrEventClassName = "TestEventClass");
  7. The server stores the EventClassName and returns S_OK.

To store an event class:

  1. The client activates the class ID CLSID_EventSystem to get the EventSystem DCOM object on the server.

  2. The client calls Store on the EventSystem DCOM object with the "EventSystem.EventClass".

     Store([in] BSTR ProgID = "EventSystem.EventClass",
       [in] IUnknown* pInterface = {pointer to CLSID_EventClass 
                                    interface created above}
  3. The server verifies the values that are specified in the event class object. In this example, it verifies that the EventClassID is not already in its event class store. If it were, the server would update the current entry with a new value for the properties and return S_OK. However, in this example, it is not already in the store, and so the server creates an entry for the event class in its store and returns S_OK.