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.

141 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. seolib2.h
  5. Abstract:
  6. This module contains definitions for useful utility
  7. classes and functions for the Server Extentions Object
  8. system.
  9. Author:
  10. Don Dumitru (dondu@microsoft.com)
  11. Revision History:
  12. dondu 06/22/98 Created.
  13. --*/
  14. class __declspec(uuid("208DB171-097B-11d2-A011-00C04FA37348")) CEDEnumGUID :
  15. public IEnumGUID, // list this first
  16. public CComObjectRootEx<CComMultiThreadModelNoCS>
  17. {
  18. public:
  19. DECLARE_PROTECT_FINAL_CONSTRUCT();
  20. DECLARE_GET_CONTROLLING_UNKNOWN();
  21. DECLARE_NOT_AGGREGATABLE(CEDEnumGUID);
  22. BEGIN_COM_MAP(CEDEnumGUID)
  23. COM_INTERFACE_ENTRY(IEnumGUID)
  24. COM_INTERFACE_ENTRY_IID(__uuidof(CEDEnumGUID),CEDEnumGUID)
  25. END_COM_MAP()
  26. public:
  27. CEDEnumGUID() {
  28. m_dwIdx = 0;
  29. m_ppGUID = NULL;
  30. };
  31. static HRESULT CreateNew(IUnknown **ppUnkNew, const GUID **ppGUID, DWORD dwIdx=0) {
  32. HRESULT hrRes;
  33. CComQIPtr<CEDEnumGUID,&__uuidof(CEDEnumGUID)> pInit;
  34. if (ppUnkNew) {
  35. *ppUnkNew = NULL;
  36. }
  37. if (!ppUnkNew) {
  38. return (E_POINTER);
  39. }
  40. if (!ppGUID) {
  41. return E_INVALIDARG;
  42. }
  43. hrRes = CComObject<CEDEnumGUID>::_CreatorClass::CreateInstance(NULL,
  44. __uuidof(IEnumGUID),
  45. (LPVOID *) ppUnkNew);
  46. if (SUCCEEDED(hrRes)) {
  47. pInit = *ppUnkNew;
  48. if (!pInit) {
  49. hrRes = E_NOINTERFACE;
  50. }
  51. }
  52. if (SUCCEEDED(hrRes)) {
  53. hrRes = pInit->InitNew(dwIdx,ppGUID);
  54. }
  55. if (!SUCCEEDED(hrRes) && *ppUnkNew) {
  56. (*ppUnkNew)->Release();
  57. *ppUnkNew = NULL;
  58. }
  59. return (hrRes);
  60. };
  61. // IEnumGUID
  62. public:
  63. HRESULT STDMETHODCALLTYPE Next(ULONG celt, GUID *pelt, ULONG *pceltFetched) {
  64. HRESULT hrRes = S_FALSE;
  65. if (!m_ppGUID) {
  66. return (E_FAIL);
  67. }
  68. if (pceltFetched) {
  69. *pceltFetched = 0;
  70. }
  71. if (!pelt) {
  72. return (E_POINTER);
  73. }
  74. if ((celt > 1) && !pceltFetched) {
  75. return (E_INVALIDARG);
  76. }
  77. while (celt && (*(m_ppGUID[m_dwIdx]) != GUID_NULL)) {
  78. *pelt = *(m_ppGUID[m_dwIdx]);
  79. pelt++;
  80. celt--;
  81. m_dwIdx++;
  82. if (pceltFetched) {
  83. (*pceltFetched)++;
  84. }
  85. }
  86. if (!celt) {
  87. hrRes = S_OK;
  88. }
  89. return (hrRes);
  90. };
  91. HRESULT STDMETHODCALLTYPE Skip(ULONG celt) {
  92. HRESULT hrRes = S_FALSE;
  93. if (!m_ppGUID) {
  94. return (E_FAIL);
  95. }
  96. while (celt && (*(m_ppGUID[m_dwIdx]) != GUID_NULL)) {
  97. celt--;
  98. m_dwIdx++;
  99. }
  100. if (!celt) {
  101. hrRes = S_OK;
  102. }
  103. return (hrRes);
  104. };
  105. HRESULT STDMETHODCALLTYPE Reset() {
  106. m_dwIdx = 0;
  107. return (S_OK);
  108. };
  109. HRESULT STDMETHODCALLTYPE Clone(IEnumGUID **ppClone) {
  110. return (CreateNew((IUnknown **) ppClone,m_ppGUID,m_dwIdx));
  111. };
  112. private:
  113. HRESULT InitNew(DWORD dwIdx, const GUID **ppGUID) {
  114. m_dwIdx = dwIdx;
  115. m_ppGUID = ppGUID;
  116. return (S_OK);
  117. };
  118. DWORD m_dwIdx;
  119. const GUID **m_ppGUID;
  120. };