如何在 COM 中创建返回接口(interface)指针的方法,这需要在 IDL 文件中完成。
编辑:
我如何在类中实现它:
STDMETHODIMP CBlah::get_Something(IOtherBlah** retval){
return m_protectedvar->QueryInterface(retval);
}
STDMETHODIMP CBlah::put_Somthing(IOtherBlah* rhs){
m_protectedvar = rhs;
return S_OK;
}
以上是行不通的。我收到以下错误:
cannot instantiate abstract class with[ Base=Blah ] due to following members:
'HRESULT IBlah::putref_Something(IOtherBlah*)' : is abstract
最佳答案
像这样:
interface IYourInterface {
HRESULT GetPointer( [out, retval]IInterface** );
};
调用者会这样调用它:
IInterface* pointer = 0;
HRESULT hr = yourInterfacePointer->GetPointer( &pointer );
关于COM - 如何创建返回接口(interface)指针的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2139545/