Developers Workshop to COM and ATL 3.0

 < Free Open Study > 


This chapter addressed the all-important idea of scriptable COM objects. As you have learned, not all COM languages are able to work with your custom vTable interfaces, and for them, we have IDispatch. This standard COM interface allows the dumb clients to access your server using a level of indirection provided by a dynamic lookup of numerical cookies and a resulting method invocation.

We examined a number of ways to build a dispinterface, and as you are sure to agree, ATL allows you to support IDispatch with no fuss. However, you did discover a very important issue in late binding: Dumb clients can only access the [default] dual interface of your coclass. We examined one approach to keep everyone happy, which was to establish a single [dual] coclass that allows your scripting clients to access the same functionality as vTable-able clients.

To safely extend your coclass with new behavior, add vTable interfaces to the object, and echo the changes in your default dual by adding additional DISPIDs. The ATL framework and IDispatchImpl<> ensure the correct methods will be called by both early and late bound clients.


 < Free Open Study > 

Категории