How to create a method in COM that returns a pointer to an interface, this needs to be done inside the IDL file.
EDIT:
How do I implement this within a class:
STDMETHODIMP CBlah::get_Something(IOtherBlah** retval){
return m_protectedvar->QueryInterface(retval);
}
STDMETHODIMP CBlah::put_Somthing(IOtherBlah* rhs){
m_protectedvar = rhs;
return S_OK;
}
The above is not working. I'开发者_JAVA技巧m getting the following error:
cannot instantiate abstract class with[ Base=Blah ] due to following members:
'HRESULT IBlah::putref_Something(IOtherBlah*)' : is abstract
Something like this:
interface IYourInterface {
HRESULT GetPointer( [out, retval]IInterface** );
};
The caller will call it like this:
IInterface* pointer = 0;
HRESULT hr = yourInterfacePointer->GetPointer( &pointer );
[ attributes here...]
interface IBlah : IDispatch {
[id(1), propget] HRESULT Something([out,retval] IOtherBlah** retval);
[id(1), propputref] HRESULT Something([in] IOtherBlah* rhs);
};
精彩评论