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.

101 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 1999
  5. //
  6. // File:
  7. //
  8. // Contents: Common routines for dealing with INetCfg interfaces.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 24 Mar 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _NCNETCFG_H_
  17. #define _NCNETCFG_H_
  18. #include "netcfgx.h"
  19. #include "nccom.h"
  20. HRESULT
  21. HrFindComponents (
  22. INetCfg* pnc,
  23. ULONG cComponents,
  24. const GUID** apguidClass,
  25. const LPCWSTR* apszwComponentId,
  26. INetCfgComponent** apncc);
  27. //------------------------------------------------------------------------
  28. // CIterNetCfgComponent - iterator for IEnumNetCfgComponent
  29. //
  30. // This class is is a simple wrapper around CIEnumIter with a call
  31. // to INetCfgClass::EnumComponents to get the enumerator.
  32. //
  33. class CIterNetCfgComponent : public CIEnumIter<IEnumNetCfgComponent, INetCfgComponent*>
  34. {
  35. public:
  36. CIterNetCfgComponent (INetCfg* pnc, const GUID* pguid) NOTHROW;
  37. CIterNetCfgComponent (INetCfgClass* pncclass) NOTHROW;
  38. ~CIterNetCfgComponent () NOTHROW { ReleaseObj(m_pec); m_pec = NULL; }
  39. protected:
  40. IEnumNetCfgComponent* m_pec;
  41. };
  42. inline CIterNetCfgComponent::CIterNetCfgComponent(INetCfg* pnc, const GUID* pguid) NOTHROW
  43. : CIEnumIter<IEnumNetCfgComponent, INetCfgComponent*> (NULL)
  44. {
  45. // If EnumComponents() fails, make sure ReleaseObj() won't die.
  46. m_pec = NULL;
  47. INetCfgClass* pncclass = NULL;
  48. m_hrLast = pnc->QueryNetCfgClass(pguid, IID_INetCfgClass,
  49. reinterpret_cast<void**>(&pncclass));
  50. if (SUCCEEDED(m_hrLast) && pncclass)
  51. {
  52. // Get the enumerator and set it for the base class.
  53. // Important to set m_hrLast so that if this fails, we'll also
  54. // fail any subsequent calls to HrNext.
  55. m_hrLast = pncclass->EnumComponents(&m_pec);
  56. if (SUCCEEDED(m_hrLast))
  57. {
  58. SetEnumerator(m_pec);
  59. }
  60. ReleaseObj(pncclass);
  61. pncclass = NULL;
  62. }
  63. // TraceHr (ttidError, FAL, m_hrLast, FALSE,
  64. // "CIterNetCfgComponent::CIterNetCfgComponent");
  65. }
  66. inline CIterNetCfgComponent::CIterNetCfgComponent(INetCfgClass* pncclass) NOTHROW
  67. : CIEnumIter<IEnumNetCfgComponent, INetCfgComponent*> (NULL)
  68. {
  69. // AssertH(pncclass);
  70. // If EnumComponents() fails, make sure ReleaseObj() won't die.
  71. m_pec = NULL;
  72. // Get the enumerator and set it for the base class.
  73. // Important to set m_hrLast so that if this fails, we'll also
  74. // fail any subsequent calls to HrNext.
  75. m_hrLast = pncclass->EnumComponents(&m_pec);
  76. if (SUCCEEDED(m_hrLast))
  77. {
  78. SetEnumerator(m_pec);
  79. }
  80. // TraceHr (ttidError, FAL, m_hrLast, FALSE,
  81. // "CIterNetCfgComponent::CIterNetCfgComponent");
  82. }
  83. #endif // _NCNETCFG_H_