Undocumented Corner Column by George Shepherd and Scot Wingo Listing One ISomeInterface* pSomeInterface = NULL; HRESULT hr; hr = CoCreateInstance(CLSID_SomeObject, NULL, CLSCTX_ALL, IID_ISomeInterface, *pSomeInterface); if(SUCCEEDED(hr)) { pSomeInterface->Function1(); pSomeInterface->Function2(); pSomeInterface->Release(); } Listing Two interface IConnectionPoint : IUnknown { HRESULT GetConnectionInterface(IID *pIID) = 0; HRESULT GetConnectionPointContainer(IConnectionPointContainer **ppCPC) = 0; HRESULT Advise(IUnknown *pUnk, DWORD *pdwCookie) = 0; HRESULT Unadvise(DWORD dwCookie) = 0; HRESULT EnumConnections(IEnumConnections **ppEnum) = 0; }; Listing Three interface IConnectionPointContainer : IUnknown { HRESULT EnumConnectionPoints(IEnumConnectionPoints **ppEnum) = 0; HRESULT FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP) = 0; }; Listing Four class ATL_NO_VTABLE CConnectableObj : public CComObjectRootEx, public CComCoClass, public IConnectionPointContainerImpl, public IDispatchImpl { ... }; Listing Five [ uuid(5BE91C40-BA0D-11D1-8CAA-D099043C7E50), version(1.0), helpstring("connectableobjsvr 1.0 Type Library") ] library CONNECTABLEOBJSVRLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); [ uuid(21C85C43-0BFF-11d1-8CAA-FD10872CC837), helpstring("Events created from the control") ] dispinterface _DSomeEvents { properties: methods: [id(1)] void Event1([in]short x, [in] short y); [id(2)] void Event2([in] float x); [id(3)] void Event3(); } [ uuid(5BE91C4E-BA0D-11D1-8CAA-D099043C7E50), helpstring("ConnectableObj Class") ] coclass ConnectableObj { [default] interface IConnectableObj; [default, source] dispinterface _DSomeEvents; }; } Listing Six template class CProxy_DSomeEvents : public IConnectionPointImpl { public: //methods: //_DSomeEvents : IDispatch public: void Fire_Event1(short x, short y) { // gnarly code for calling // IDispatch::Invoke() } void Fire_Event2(float x) { // gnarly code for calling // IDispatch::Invoke() } void Fire_Event3() { // gnarly code for calling // IDispatch::Invoke() } }; Listing Seven BEGIN_CONNECTION_POINT_MAP(CConnectableObj) CONNECTION_POINT_ENTRY(DIID__DSomeEvents) END_CONNECTION_POINT_MAP() 3