枚举器的定义,不使用ATL提供的枚举器定义
[id(1), propget] HRESULT Count([out, retval] long* pCount);
[id(2), propget] HRESULT Item([in] long Index, [out, retval] IUnknown** pUnknown);
[id(3), propget] HRESULT _NewEnum([out, retval] IUnknown** ppUnk);
STDMETHOD(get_Count)(long *nCount);
STDMETHOD(get_Item)(long nIndex, IUnknown **pItem);
STDMETHOD(get__NewEnum)(IUnknown **punk);
class CEnumUnknownShellList : public IEnumUnknown
, public CComObjectRootEx<CComObjectThreadModel>
{
HRESULT Init(CYouClassName *pYouClasName)
{
m_pPopupMenuBar = pPopupMenuBar;
return S_OK;
}
STDMETHOD(Next)(ULONG celt, IUnknown** rgelt, ULONG* pceltFetched);
STDMETHOD(Skip)(ULONG celt);
STDMETHOD(Reset)(void);
STDMETHOD(Clone)(IEnumUnknown** ppEnum);
BEGIN_COM_MAP(CEnumUnknownMenuItem)
COM_INTERFACE_ENTRY_IID(IID_IEnumUnknown, IEnumUnknown)
END_COM_MAP()
protected:
private:
int m_nItem;
CYouClassName *m_pYouClasName;
};