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.

150 lines
3.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N C N E T C O N . H
  7. //
  8. // Contents: Common routines for dealing with the connections interfaces.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 25 Jan 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _NCNETCON_H_
  17. #define _NCNETCON_H_
  18. #include "nccom.h"
  19. #include "netconp.h"
  20. #include "oleauto.h"
  21. typedef enum tagNETCONPROPS_EX_FIELDS
  22. {
  23. NCP_DWSIZE = 0,
  24. NCP_GUIDID,
  25. NCP_BSTRNAME,
  26. NCP_BSTRDEVICENAME,
  27. NCP_NCSTATUS,
  28. NCP_MEDIATYPE,
  29. NCP_SUBMEDIATYPE,
  30. NCP_DWCHARACTER,
  31. NCP_CLSIDTHISOBJECT,
  32. NCP_CLSIDUIOBJECT,
  33. NCP_BSTRPHONEORHOSTADDRESS,
  34. NCP_BSTRPERSISTDATA,
  35. NCP_MAX = NCP_BSTRPERSISTDATA,
  36. NCP_ELEMENTS = NCP_MAX + 1
  37. } NETCONPROPS_EX_FIELDS;
  38. BOOL
  39. FAnyReasonToEnumerateConnectionsForShowIconInfo (
  40. VOID);
  41. BOOL
  42. FIsValidConnectionName(
  43. IN PCWSTR pszName);
  44. VOID
  45. FreeNetconProperties (
  46. IN NETCON_PROPERTIES* pProps);
  47. HRESULT
  48. HrGetConnectionPersistData (
  49. IN INetConnection* pConn,
  50. OUT BYTE** ppbData,
  51. OUT ULONG* pulSize,
  52. OUT CLSID* pclsid OPTIONAL);
  53. HRESULT
  54. HrGetConnectionFromPersistData (
  55. IN const CLSID& clsid,
  56. IN const BYTE* pbData,
  57. IN ULONG cbData,
  58. IN REFIID riid,
  59. OUT VOID** ppv);
  60. //------------------------------------------------------------------------
  61. // CIterNetCon - iterator for IEnumNetConnection
  62. //
  63. // This class is is a simple wrapper around CIEnumIter with a call
  64. // to INetConnectionManager::EnumConnections to get the enumerator.
  65. //
  66. class CIterNetCon : public CIEnumIter<IEnumNetConnection, INetConnection*>
  67. {
  68. public:
  69. NOTHROW CIterNetCon (
  70. INetConnectionManager* pConMan,
  71. NETCONMGR_ENUM_FLAGS Flags);
  72. NOTHROW ~CIterNetCon () { ReleaseObj (m_pEnum); }
  73. // Specialization to set the proxy blanket before returning
  74. NOTHROW HRESULT HrNext(INetConnection ** ppConnection);
  75. protected:
  76. IEnumNetConnection* m_pEnum;
  77. };
  78. inline NOTHROW CIterNetCon::CIterNetCon (
  79. INetConnectionManager* pConMan,
  80. NETCONMGR_ENUM_FLAGS Flags
  81. )
  82. : CIEnumIter<IEnumNetConnection, INetConnection*> (NULL)
  83. {
  84. AssertH (pConMan);
  85. // If EnumConnections() fails, make sure ReleaseObj() won't die.
  86. m_pEnum = NULL;
  87. // Get the enumerator and set it for the base class.
  88. // Important to set m_hrLast so that if this fails, we'll also
  89. // fail any subsequent calls to HrNext.
  90. //
  91. m_hrLast = pConMan->EnumConnections (Flags, &m_pEnum);
  92. TraceHr (ttidError, FAL, m_hrLast, FALSE,
  93. "INetConnectionManager->EnumConnections");
  94. if (SUCCEEDED(m_hrLast))
  95. {
  96. NcSetProxyBlanket (m_pEnum);
  97. SetEnumerator (m_pEnum);
  98. }
  99. TraceHr (ttidError, FAL, m_hrLast, FALSE, "CIterNetCon::CIterNetCon");
  100. }
  101. // Specialization to set the proxy blanket before returning
  102. inline NOTHROW HRESULT CIterNetCon::HrNext(INetConnection ** ppConnection)
  103. {
  104. HRESULT hr = CIEnumIter<IEnumNetConnection, INetConnection*>::HrNext(ppConnection);
  105. if(SUCCEEDED(hr) && *ppConnection)
  106. {
  107. NcSetProxyBlanket(*ppConnection);
  108. }
  109. return hr;
  110. }
  111. VOID
  112. SetOrQueryAtLeastOneLanWithShowIcon (
  113. IN BOOL fSet,
  114. IN BOOL fSetValue,
  115. OUT BOOL* pfQueriedValue);
  116. HRESULT
  117. HrSafeArrayFromNetConPropertiesEx (
  118. IN NETCON_PROPERTIES_EX* pPropsEx,
  119. OUT SAFEARRAY** ppsaProperties);
  120. HRESULT HrNetConPropertiesExFromSafeArray(
  121. IN SAFEARRAY* psaProperties,
  122. OUT NETCON_PROPERTIES_EX** pPropsEx);
  123. HRESULT HrFreeNetConProperties2(
  124. NETCON_PROPERTIES_EX* pPropsEx);
  125. #endif // _NCNETCON_H_