#include extern GUID g_IID_Library; extern unsigned short g_MajVerNo, g_MinVerNo; extern LCID g_LCID; /* The destructor is declared as virtual because we want all the destructors to be called even if delete X is applied to an object masquerading as a higher level class. To avoid this occupying space in the main vtable and thereby confusing OLE, the virtual destructor is derived from a different base class. The method for returning a reference to the class ID is put here as well to avoid the main vtable ... */ struct VirtualDestructor { virtual ~VirtualDestructor(); virtual GUID & IID_This(void) = 0; }; /* OLE automation classes may safely be derived from this one provided that the IID_Library for the type library is defined and the method IID_This() is implemented */ struct SimpleDispatch : IDispatch, VirtualDestructor { unsigned long m_refs; SimpleDispatch(); // constructor sets ref count to one // IUnknown methods ... HRESULT __stdcall QueryInterface(REFIID riid, void **ppv); unsigned long __stdcall AddRef(void); unsigned long __stdcall Release(void); // IDispatch methods ... HRESULT __stdcall GetTypeInfoCount(unsigned int *pctinfo); HRESULT __stdcall GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo **pptinfo); HRESULT __stdcall GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, unsigned int cNames, LCID lcid, DISPID *rgdispid); HRESULT __stdcall Invoke(DISPID dispidMember, REFIID riid, LCID lcid, unsigned short wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, unsigned int *puArgErr); };