[uuid(C7E9002B-9E7F-43b5-971D-E2539E6039C2), version(1.0), helpstring ("COMDemo: Demo of COM object defined in C++")] library COMDemo { importlib("stdole2.tlb"); [uuid(2BB79939-EE89-4ae0-BF7D-E7FB175A87CF), oleautomation, dual, hidden] interface SimpleDispatch : IDispatch { /* These two methods are just to occupy two slots in the virtual function table. They will never be directly called by a container ... */ [hidden] HRESULT VirtualDestructor([in]IUnknown *stream); // spurious parameter hides function from Excel [hidden] IUnknown *IID_This(); // incorrect parameter hides function from Excel }; // Custom class definitions ... [uuid(7C8721D6-3D22-48a1-A945-5FF9815C5807), odl, oleautomation, dual, helpstring("Name/value pair")] interface ITestObj : SimpleDispatch { [propget, helpstring("Name of quantity")] HRESULT Name([out,retval]BSTR *); [propput] HRESULT Name([in]BSTR); [propget, id(0), helpstring("Value (default property)")] HRESULT Value([out, retval]double *); [propput, id(0)] HRESULT Value([in]double); [helpstring("Square of value")] HRESULT Square([out,retval]double *square); }; [uuid(5FC711F1-B9C7-4dcc-8CCC-E39F9E0F7556)] coclass TestObj { interface ITestObj; }; // Repeat for further classes. This one exposes two Excel worksheet functions ... [uuid(7C2676F0-142F-4898-AD85-404F52AF9559), odl, oleautomation, dual, helpstring("COMDemo: test worksheet functions interface")] interface ITestWorksheetFuncs : SimpleDispatch { HRESULT AddTwoNumbers([in]VARIANT *Number1, [in]VARIANT *Number2, [out, retval]VARIANT *); HRESULT JoinTwoStrings([in]VARIANT *String1, [in]VARIANT *String2, [out, retval]VARIANT *ret); } [uuid(ABA0BF16-855F-475a-8D8D-3DA02CFAFDAC), helpstring("COMDemo: test worksheet functions")] coclass TestWorksheetFuncs { interface ITestWorksheetFuncs; }; };