3.4.2 A simple implementation of a single Automation interface

In the case where you are implementing a single dispinterface that was designed by someone else, for example an event sink, you can usually avoid needing to parse a type library or define a class to implement the interface.

Instead, you implement a dispinterface using the class simple-i-dispatch by doing the following:

  1. Obtain an interface pointer that will provide type information for the component, to be used as the related-dispatch argument in the call to the function query-simple-i-dispatch-interface. In the case where you are implementing an event sink, the source interface pointer will usually do this.
  2. Optionally, define a class with defclass inheriting from simple-i-dispatch. The class simple-i-dispatch can be used itself if no special callback object is required.
  3. Implement an invoke-callback that selects and implements the methods of the interface.
  4. Define initialization code which calls co-initialize, obtains the related-dispatch from step 1, makes an instance of the COM object class defined in step 2 with the invoke-callback from step 3, obtains its interface pointer by calling query-simple-i-dispatch-interface (passing the related-dispatch ) and attaches this interface pointer to the appropriate sink in the related-dispatch (for example using connection point functions such as interface-connect). This must all be done in a thread that will be processing Windows messages (for instance a CAPI thread).

LispWorks COM/Automation User Guide and Reference Manual - 23 Mar 2005