The problem is that your
IZInterface
is not derived (according to your code) from
IBClass
, therefore it doesn't have the method
Method1
. Your code should look something like
[
object,
uuid(8CA6DBF2-E402-464D-96AE-3D6642D91E14),
pointer_default(unique)
]
interface IBClass : IDispatch{
[] HRESULT Method11([out,retval] LONG* l);
};
[
object,
uuid(7359AF6C-6E90-4372-991F-556602CB3977),
dual,
nonextensible,
pointer_default(unique)
]
interface IZInterface : IBClass{ [id(1)] HRESULT ZGetStr([out,retval] BSTR* str);
[id(2)] HRESULT GetSize([in,out] LONG* nSize);
};
library DllStandardLib
{
importlib("stdole2.tlb");
[
uuid(491DF659-012F-4C20-90AA-0CBC5BDE5A68)
]
coclass ZInterface
{
[default] interface IZInterface;
};
[
uuid(43CE897F-17F2-4D45-9098-26B7AEE6EC23)
]
coclass BClass
{
[default] interface IBClass;
};
};
Thanks to Microsoft
"The current implementation of MIDL does not handle function overloading or multiple inheritance". So your IBClass can be inherited from
IDispatch
rather than from
IUnknown
. But you can try to emulate multiple inheritance by writing some of your classes in C++. For example, here is the definition of
IDispatch
from OAIdl.h
MIDL_INTERFACE("00020400-0000-0000-C000-000000000046")
IDispatch : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(
__RPC__out UINT *pctinfo) = 0;
virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(
UINT iTInfo,
LCID lcid,
__RPC__deref_out_opt ITypeInfo **ppTInfo) = 0;
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(
__RPC__in REFIID riid,
__RPC__in_ecount_full(cNames) LPOLESTR *rgszNames,
__RPC__in_range(0,16384) UINT cNames,
LCID lcid,
__RPC__out_ecount_full(cNames) DISPID *rgDispId) = 0;
virtual HRESULT STDMETHODCALLTYPE Invoke(
_In_ DISPID dispIdMember,
_In_ REFIID riid,
_In_ LCID lcid,
_In_ WORD wFlags,
_In_ DISPPARAMS *pDispParams,
_Out_opt_ VARIANT *pVarResult,
_Out_opt_ EXCEPINFO *pExcepInfo,
_Out_opt_ UINT *puArgErr) = 0;
};
Then just include your header in your IDL.