Compartir a través de


Implementing CComObjectRootEx

CComObjectRootEx is essential; all ATL objects must have one instance of CComObjectRootEx or CComObjectRoot in their inheritance. CComObjectRootEx provides the default QueryInterface mechanism based on COM map entries.

Through its COM map, an object's interfaces are exposed to a client when the client queries for an interface. The query is performed through CComObjectRootEx::InternalQueryInterface. InternalQueryInterface only handles interfaces in the COM map table.

You can enter interfaces into the COM map table with the COM_INTERFACE_ENTRY macro or one of its variants. For example, the following code enters the interfaces IDispatch, IBeeper, and ISupportErrorInfo into the COM map table:

BEGIN_COM_MAP(CBeeper)
   COM_INTERFACE_ENTRY(IBeeper)
   COM_INTERFACE_ENTRY(IDispatch)
   COM_INTERFACE_ENTRY_TEAR_OFF(IID_ISupportErrorInfo, CBeeper2)
END_COM_MAP()

See Also

Reference

Fundamentals of ATL COM Objects

Other Resources

COM Map Macros