描述:
我现在获得了一个Collection,我想取得其中的每个元素。但是其接口没有封装item等方法,只提供了_NewEnum()方法,我用以下方法,有问题,请指教。
IUnknownPtr ptr;
ptr=dsoPartitionAnalyzer->DesignedAggregations->_NewEnum();
其中dsoPartitionAnalyzer->DesignedAggregations是一个_Collection
inline IUnknownPtr _Collection::_NewEnum ( )
{
IUnknown * _result;
HRESULT _hr = raw__NewEnum(&_result);/////////这儿出错了
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return IUnknownPtr(_result, false)
}
在msado15.tlh中定义:
_Collection : IDispatch
{
//
// Property data
//
__declspec(property(get=GetCount))
long Count;
//
// Wrapper methods for error-handling
//
long GetCount ( );
IUnknownPtr _NewEnum ( );
HRESULT Refresh ( );
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall get_Count (
long * c ) = 0;
virtual HRESULT __stdcall raw__NewEnum (
IUnknown * * ppvObject ) = 0;
virtual HRESULT __stdcall raw_Refresh ( ) = 0;
};