Source code of Windows XP (NT5)
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.

254 lines
3.9 KiB

  1. //
  2. // Copyright 1997 - Microsoft
  3. //
  4. // CENUMSIF.CPP - Handles enumerating OSes and Tools SIFs from DS
  5. //
  6. #include "pch.h"
  7. DEFINE_MODULE("IMADMUI")
  8. DEFINE_THISCLASS("CEnumSAPs")
  9. #define THISCLASS CEnumSAPs
  10. #define LPTHISCLASS LPCENUMSAPS
  11. // ************************************************************************
  12. //
  13. // Constructor / Destructor
  14. //
  15. // ************************************************************************
  16. //
  17. // CreateInstance()
  18. //
  19. LPVOID
  20. CEnumSAPs_CreateInstance( LPWSTR pszObjectName )
  21. {
  22. TraceFunc( "CEnumSAPs_CreateInstance(" );
  23. TraceMsg( TF_FUNC, "pszObjectName = %s )\n", pszObjectName );
  24. LPTHISCLASS lpcc = new THISCLASS( );
  25. HRESULT hr = THR( lpcc->Init( pszObjectName ) );
  26. if ( hr )
  27. {
  28. delete lpcc;
  29. RETURN(NULL);
  30. }
  31. RETURN((LPVOID) lpcc);
  32. }
  33. //
  34. // Constructor
  35. //
  36. THISCLASS::THISCLASS( )
  37. {
  38. TraceClsFunc( "CEnumSAPs()\n" );
  39. InterlockIncrement( g_cObjects );
  40. TraceFuncExit();
  41. }
  42. //
  43. // Init()
  44. //
  45. STDMETHODIMP
  46. THISCLASS::Init( LPWSTR pszObjectName )
  47. {
  48. HRESULT hr = S_OK;
  49. TraceClsFunc( "Init()\n" );
  50. // IUnknown stuff
  51. BEGIN_QITABLE_IMP( CEnumSAPs, IEnumSAPs );
  52. QITABLE_IMP( IEnumSAPs );
  53. END_QITABLE_IMP( CEnumSAPs );
  54. Assert( _cRef == 0);
  55. AddRef( );
  56. // Private Members
  57. Assert( _iIndex == 0 );
  58. Assert( _penum == NULL );
  59. RETURN(hr);
  60. }
  61. //
  62. // Destructor
  63. //
  64. THISCLASS::~THISCLASS( )
  65. {
  66. TraceClsFunc( "~CEnumSAPs()\n" );
  67. // Private Members
  68. if ( _penum )
  69. _penum->Release( );
  70. InterlockDecrement( g_cObjects );
  71. TraceFuncExit();
  72. };
  73. // ************************************************************************
  74. //
  75. // IUnknown
  76. //
  77. // ************************************************************************
  78. //
  79. // QueryInterface()
  80. //
  81. STDMETHODIMP
  82. THISCLASS::QueryInterface(
  83. REFIID riid,
  84. LPVOID *ppv )
  85. {
  86. TraceClsFunc( "[IUnknown] QueryInterface( riid=" );
  87. HRESULT hr = ::QueryInterface( this, _QITable, riid, ppv );
  88. QIRETURN( hr, riid );
  89. }
  90. //
  91. // AddRef()
  92. //
  93. STDMETHODIMP_(ULONG)
  94. THISCLASS::AddRef( void )
  95. {
  96. TraceClsFunc( "[IUnknown] AddRef( )\n" );
  97. InterlockIncrement( _cRef );
  98. RETURN(_cRef);
  99. }
  100. //
  101. // Release()
  102. //
  103. STDMETHODIMP_(ULONG)
  104. THISCLASS::Release( void )
  105. {
  106. TraceClsFunc( "[IUnknown] Release( )\n" );
  107. InterlockDecrement( _cRef );
  108. if ( _cRef )
  109. RETURN(_cRef);
  110. TraceDo( delete this );
  111. RETURN(0);
  112. }
  113. // ************************************************************************
  114. //
  115. // IEnumSAPs
  116. //
  117. // ************************************************************************
  118. //
  119. // Next( )
  120. //
  121. STDMETHODIMP
  122. THISCLASS::Next(
  123. ULONG celt,
  124. VARIANT * rgelt,
  125. ULONG * pceltFetched )
  126. {
  127. TraceClsFunc( "[IEnumSAPs] Next( ... )\n " );
  128. if ( !rgelt )
  129. RRETURN(E_POINTER);
  130. HRESULT hr;
  131. if (pceltFetched)
  132. *pceltFetched = 0;
  133. //
  134. // Get the attribute vars
  135. //
  136. hr = THR( _penum->Next( celt, rgelt, pceltFetched ) );
  137. if (hr)
  138. goto Error;
  139. Cleanup:
  140. RETURN(hr);
  141. Error:
  142. switch (hr) {
  143. case S_OK:
  144. break;
  145. default:
  146. MessageBoxFromHResult( NULL, IDC_ERROR_CREATINGACCOUNT_TITLE, hr );
  147. break;
  148. }
  149. goto Cleanup;
  150. }
  151. //
  152. // Skip( )
  153. //
  154. STDMETHODIMP
  155. THISCLASS::Skip(
  156. ULONG celt )
  157. {
  158. TraceClsFunc( "[IEnumSAPs] Skip( ... )\n " );
  159. HRESULT hr = S_OK;
  160. hr = THR( _penum->Skip( celt ) );
  161. if (hr)
  162. goto Error;
  163. Error:
  164. RETURN(hr);
  165. }
  166. //
  167. // Reset( )
  168. //
  169. STDMETHODIMP
  170. THISCLASS::Reset( void )
  171. {
  172. TraceClsFunc( "[IEnumSAPs] Reset( ... )\n " );
  173. HRESULT hr = S_OK;
  174. hr = THR( _penum->Reset( ) );
  175. if (hr)
  176. goto Error;
  177. Error:
  178. RETURN(hr);
  179. }
  180. //
  181. // Clone( )
  182. //
  183. STDMETHODIMP
  184. THISCLASS::Clone(
  185. LPUNKNOWN * ppenum )
  186. {
  187. TraceClsFunc( "[IEnumSAPs] Clone( ... )\n" );
  188. if ( ppenum == NULL )
  189. RRETURN( E_POINTER );
  190. *ppenum = NULL;
  191. hr = THR( _penum->Clone( ppenum ) );
  192. if (hr)
  193. goto Error;
  194. Error:
  195. RETURN(hr);
  196. }