Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.5 KiB

  1. // EnumerateAdapterInfo.h : Declaration of the CAdapterInfo
  2. #pragma once
  3. #include "resource.h" // main symbols
  4. #include "AdapterInfo.h"
  5. #include <list>
  6. #include "CollectionAdapters.h"
  7. //
  8. // Store the data in a vector of std::strings
  9. //
  10. typedef CComEnumOnSTL<IEnumAdapterInfo, &IID_IEnumAdapterInfo, IAdapterInfo*, _CopyInterface<IAdapterInfo>, LISTOF_ADAPTERS> ComEnumOnSTL_ForAdapters;
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CEnumAdapterInfo
  13. //
  14. class ATL_NO_VTABLE CEnumAdapterInfo :
  15. public ComEnumOnSTL_ForAdapters,
  16. public CComCoClass<CEnumAdapterInfo, &CLSID_EnumAdapterInfo>
  17. {
  18. public:
  19. CEnumAdapterInfo()
  20. {
  21. }
  22. DECLARE_REGISTRY_RESOURCEID(IDR_MAPCOLLECTION)
  23. DECLARE_PROTECT_FINAL_CONSTRUCT()
  24. BEGIN_COM_MAP(CEnumAdapterInfo)
  25. COM_INTERFACE_ENTRY(IEnumAdapterInfo)
  26. END_COM_MAP()
  27. };
  28. //
  29. // Helper template to create the IEnum
  30. //
  31. template <class EnumType, class CollType>
  32. HRESULT CreateSTLEnumerator(IUnknown** ppUnk, IUnknown* pUnkForRelease, CollType& collection)
  33. {
  34. if (ppUnk == NULL)
  35. return E_POINTER;
  36. *ppUnk = NULL;
  37. CComObject<EnumType>* pEnum = NULL;
  38. HRESULT hr = CComObject<EnumType>::CreateInstance(&pEnum);
  39. if (FAILED(hr))
  40. return hr;
  41. hr = pEnum->Init(pUnkForRelease, collection);
  42. if (SUCCEEDED(hr))
  43. hr = pEnum->QueryInterface(ppUnk);
  44. if (FAILED(hr))
  45. delete pEnum;
  46. return hr;
  47. } // CreateSTLEnumerator