// SetupClassEnum.cpp : Implementation of CSetupClassEnum #include "stdafx.h" #include "DevCon2.h" #include "SetupClass.h" #include "SetupClasses.h" #include "SetupClassEnum.h" ///////////////////////////////////////////////////////////////////////////// // CSetupClassEnum CSetupClassEnum::~CSetupClassEnum() { DWORD c; if(pSetupClasses) { for(c=0;cRelease(); } delete [] pSetupClasses; } } HRESULT CSetupClassEnum::Next( ULONG celt, VARIANT * rgVar, ULONG * pCeltFetched ) { ULONG fetched; CSetupClass *pCls; if(pCeltFetched) { *pCeltFetched = 0; } for(fetched = 0; fetchedAddRef(); V_VT(&rgVar[fetched]) = VT_DISPATCH; V_DISPATCH(&rgVar[fetched]) = pCls; } if(pCeltFetched) { *pCeltFetched = fetched; } return (fetched *pEnum = NULL; hr = CComObject::CreateInstance(&pEnum); if(FAILED(hr)) { return hr; } if(!pEnum) { return E_OUTOFMEMORY; } if(!pEnum->CopySetupClasses(pSetupClasses,Count)) { delete pEnum; return E_OUTOFMEMORY; } pEnum->Position = Position; pEnum->AddRef(); *ppEnum = pEnum; return S_OK; } BOOL CSetupClassEnum::CopySetupClasses(CSetupClass **pArray, DWORD NewCount) { DWORD c; if(pSetupClasses) { delete [] pSetupClasses; pSetupClasses = NULL; } Count = 0; Position = 0; pSetupClasses = new CSetupClass*[NewCount]; if(!pSetupClasses) { return FALSE; } for(c=0;cAddRef(); pSetupClasses[c] = pArray[c]; if(!pSetupClasses[c]) { Count = c; return FALSE; } } Count = NewCount; return TRUE; }