Phi*_*ord 2 com methods interface
如何在COM中创建一个返回指向接口的指针的方法,这需要在IDL文件中完成.
编辑:
我如何在一个类中实现它:
STDMETHODIMP CBlah::get_Something(IOtherBlah** retval){
return m_protectedvar->QueryInterface(retval);
}
STDMETHODIMP CBlah::put_Somthing(IOtherBlah* rhs){
m_protectedvar = rhs;
return S_OK;
}
Run Code Online (Sandbox Code Playgroud)
以上不起作用.我收到以下错误:
cannot instantiate abstract class with[ Base=Blah ] due to following members:
'HRESULT IBlah::putref_Something(IOtherBlah*)' : is abstract
Run Code Online (Sandbox Code Playgroud)
像这样的东西:
interface IYourInterface {
HRESULT GetPointer( [out, retval]IInterface** );
};
Run Code Online (Sandbox Code Playgroud)
来电者会这样称呼它:
IInterface* pointer = 0;
HRESULT hr = yourInterfacePointer->GetPointer( &pointer );
Run Code Online (Sandbox Code Playgroud)