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.

153 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. SessEnum.h
  5. Abstract:
  6. SessEnum.h : Declaration of the CRemoteDesktopHelpSessionEnum
  7. Author:
  8. HueiWang 2/17/2000
  9. --*/
  10. #ifndef __REMOTEDESKTOPHELPSESSIONENUM_H_
  11. #define __REMOTEDESKTOPHELPSESSIONENUM_H_
  12. #include "resource.h" // main symbols
  13. //#include "tsstl.h"
  14. //#include "HelpSess.h"
  15. typedef list< RemoteDesktopHelpSessionObj* > HelpSessionObjList;
  16. //
  17. // Why implement our own collection/enumerator -
  18. //
  19. // 1) IEnumOnSTLImpl has a copy of data in m_pCollection,
  20. // ICollectionOnSTLImpl has another copy of data in m_col1.
  21. // 2) _NewEnum() returns IUnknown*, Clone() returns IRemoteDesktopHelpSessionEnum.
  22. // 3) Item() properties is VARIANT* but Next() return array of interface.
  23. // 4) Can't combine two enumerator/collection type, compiler doesn't like
  24. // it.
  25. // 5) ATL bug in enumerator, if empty list, it returns E_FAILED instead of
  26. // S_FALSE.
  27. //
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CRemoteDesktopHelpSessionEnum
  30. class ATL_NO_VTABLE CRemoteDesktopHelpSessionEnum :
  31. public CComObjectRootEx<CComMultiThreadModel>,
  32. public CComCoClass<CRemoteDesktopHelpSessionEnum, &CLSID_RemoteDesktopHelpSessionEnum>,
  33. public IDispatchImpl<IRemoteDesktopHelpSessionEnum, &IID_IRemoteDesktopHelpSessionEnum, &LIBID_RDSESSMGRLib>
  34. {
  35. friend class CRemoteDesktopHelpSessionMgr;
  36. friend class CRemoteDesktopHelpSessionEnum;
  37. public:
  38. CRemoteDesktopHelpSessionEnum()
  39. {
  40. }
  41. ~CRemoteDesktopHelpSessionEnum()
  42. {
  43. MYASSERT(0 == m_pcollection.size() );
  44. }
  45. DECLARE_REGISTRY_RESOURCEID(IDR_REMOTEDESKTOPHELPSESSIONENUM)
  46. DECLARE_PROTECT_FINAL_CONSTRUCT()
  47. BEGIN_COM_MAP(CRemoteDesktopHelpSessionEnum)
  48. COM_INTERFACE_ENTRY(IRemoteDesktopHelpSessionEnum)
  49. COM_INTERFACE_ENTRY(IDispatch)
  50. END_COM_MAP()
  51. HRESULT
  52. FinalConstruct()
  53. {
  54. _Module.AddRef();
  55. DebugPrintf( _TEXT("Module AddRef by CRemoteDesktopHelpSessionEnum()...\n") );
  56. return S_OK;
  57. }
  58. void
  59. FinalRelease()
  60. {
  61. HelpSessionObjList::iterator it;
  62. for(it = m_pcollection.begin(); it != m_pcollection.end(); it++)
  63. {
  64. (*it)->Release();
  65. }
  66. m_pcollection.erase( m_pcollection.begin(), m_pcollection.end() );
  67. _Module.Release();
  68. DebugPrintf( _TEXT("Module Release by CRemoteDesktopHelpSessionEnum()...\n") );
  69. }
  70. // IRemoteDesktopHelpSessionEnum
  71. public:
  72. STDMETHOD(get__NewEnum)(
  73. /*[out, retval]*/ LPUNKNOWN *pVal
  74. );
  75. STDMETHOD(get_Item)(
  76. /*[in]*/ long index,
  77. /*[out, retval]*/ VARIANT* pItem
  78. );
  79. STDMETHOD(get_Count)(
  80. /*[out, retval]*/ long *pVal
  81. );
  82. STDMETHOD(Clone)(
  83. /*[out]*/ IRemoteDesktopHelpSessionEnum** ppEnum
  84. );
  85. STDMETHOD(Skip)(
  86. /*[in]*/ ULONG cCount
  87. );
  88. STDMETHOD(Reset)();
  89. STDMETHOD(Next)(
  90. /*[in]*/ ULONG uCount,
  91. /*[out, size_is(uCount), length_is(*pcFetched)]*/ IRemoteDesktopHelpSession** ppIRemoteDesktopHelpSession,
  92. /*[out]*/ ULONG* pcFetched
  93. );
  94. private:
  95. HRESULT
  96. Add(
  97. RemoteDesktopHelpSessionObj* pObj
  98. )
  99. /*++
  100. --*/
  101. {
  102. m_pcollection.push_back(pObj);
  103. //
  104. // We just store copy of interface in our list so
  105. // add one more reference to this Help object
  106. //
  107. pObj->AddRef();
  108. return S_OK;
  109. }
  110. HelpSessionObjList m_pcollection;
  111. HelpSessionObjList::iterator m_iter;
  112. };
  113. #endif //__REMOTEDESKTOPHELPSESSIONENUM_H_