#include "OleAut.h" /* GUID, etc. for the library as a whole. Must match entries in ODL ... */ GUID g_IID_Library = {0x01234567, 0x89ab, 0xcdef, 0x01, 0x23, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab}; unsigned short g_MajVerNo = 1; unsigned short g_MinVerNo = 0; LCID g_LCID = 0; // GUID for this particular object. Needed to implement IDispatch methods GUID IID_TestObj = {0xd0bed0be, 0xd000, 0xbeee, 0xd0, 0x00, 0xd0, 0xbe, 0xd0, 0xbe, 0xd0, 0xbe}; // Test object definition ... struct TestObj : SimpleDispatch { BSTR m_name; double m_value; GUID & IID_This(void) {return IID_TestObj;} // does not interfere with OLE as not in primary vtable // Property get/put ... these methods match up to the entries in the ODL file virtual HRESULT __stdcall get_name(BSTR &name) { name = SysAllocString(m_name); return NOERROR; } virtual HRESULT __stdcall put_name(BSTR name) { SysFreeString(m_name); m_name = SysAllocString(name); return NOERROR; } virtual HRESULT __stdcall get_value(double &value) { value = m_value; return NOERROR; } virtual HRESULT __stdcall put_value(double value) { m_value = value; return NOERROR; } virtual HRESULT __stdcall square(double &square) { square = m_value * m_value; return NOERROR; } }; __declspec(dllexport) TestObj * __stdcall NewTestObj(BSTR name, double value) { TestObj *to = new TestObj; to->m_name = SysAllocString(name); to->m_value = value; return to; }