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.

252 lines
5.5 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. regenumkeys.cpp
  5. Abstract:
  6. ported from vsee\lib\reg\cenumvalues.cpp
  7. Author:
  8. Jay Krell (JayKrell) August 2001
  9. Revision History:
  10. --*/
  11. #include "stdinc.h"
  12. #include "fusionregenumvalues.h"
  13. #include "fusionregkey2.h"
  14. #include "vseeport.h"
  15. /*-----------------------------------------------------------------------------
  16. Name: CRegEnumValues::CRegEnumValues
  17. @mfunc
  18. @owner
  19. -----------------------------------------------------------------------------*/
  20. F::CRegEnumValues::CRegEnumValues
  21. (
  22. HKEY hKey
  23. ) throw(CErr)
  24. :
  25. m_hKey(hKey),
  26. m_dwIndex(0),
  27. m_cValues(0),
  28. m_cchMaxValueNameLength(0),
  29. m_cbMaxValueDataLength(0),
  30. m_cbCurrentValueDataLength(0),
  31. m_dwType(0)
  32. {
  33. VSEE_ASSERT_CAN_THROW();
  34. F::CRegKey2::ThrQueryValuesInfo(hKey, &m_cValues, &m_cchMaxValueNameLength, &m_cbMaxValueDataLength);
  35. // we keep this the max size the whole time
  36. if (!m_rgbValueData.Win32SetSize(m_cbMaxValueDataLength + 2*sizeof(WCHAR)))
  37. CErr::ThrowWin32(F::GetLastWin32Error());
  38. if (*this)
  39. {
  40. ThrGet();
  41. }
  42. }
  43. /*-----------------------------------------------------------------------------
  44. Name: CRegEnumValues::operator bool
  45. @mfunc
  46. are we done yet?
  47. @owner
  48. -----------------------------------------------------------------------------*/
  49. F::CRegEnumValues::operator bool
  50. (
  51. ) const /*throw()*/
  52. {
  53. return (m_dwIndex < m_cValues);
  54. }
  55. /*-----------------------------------------------------------------------------
  56. Name: CRegEnumValues::ThrGet
  57. @mfunc
  58. get the current value name and data, called by operator++ and constructor
  59. @owner
  60. -----------------------------------------------------------------------------*/
  61. VOID
  62. F::CRegEnumValues::ThrGet
  63. (
  64. ) throw(CErr)
  65. {
  66. VSEE_ASSERT_CAN_THROW();
  67. DWORD cchValueNameLength = m_cchMaxValueNameLength;
  68. cchValueNameLength += 1; // count room for terminal nul
  69. CStringW_CFixedSizeBuffer nameBuffer(&m_strValueName, cchValueNameLength);
  70. m_cbCurrentValueDataLength = static_cast<DWORD>(m_rgbValueData.GetSize());
  71. // CONSIDER
  72. // Other places we have an "actual buffer size" and a smaller size we claim to the Reg API.
  73. // Here the actual and claimed are the same.
  74. F::CRegKey2::ThrEnumValue
  75. (
  76. m_hKey,
  77. m_dwIndex,
  78. nameBuffer,
  79. &cchValueNameLength,
  80. &m_dwType,
  81. m_rgbValueData.GetArrayPtr(),
  82. &m_cbCurrentValueDataLength
  83. );
  84. }
  85. /*-----------------------------------------------------------------------------
  86. Name: CRegEnumValues::ThrNext
  87. @mfunc
  88. move to the next value
  89. @owner
  90. -----------------------------------------------------------------------------*/
  91. VOID
  92. F::CRegEnumValues::ThrNext
  93. (
  94. ) throw(CErr)
  95. {
  96. VSEE_ASSERT_CAN_THROW();
  97. ++m_dwIndex;
  98. if (*this)
  99. {
  100. ThrGet();
  101. }
  102. }
  103. /*-----------------------------------------------------------------------------
  104. Name: CRegEnumValues::operator++
  105. @mfunc
  106. move to the next value
  107. @owner
  108. -----------------------------------------------------------------------------*/
  109. VOID
  110. F::CRegEnumValues::operator++
  111. (
  112. ) throw(CErr)
  113. {
  114. VSEE_ASSERT_CAN_THROW();
  115. ThrNext();
  116. }
  117. /*-----------------------------------------------------------------------------
  118. Name: CRegEnumValues::operator++
  119. @mfunc
  120. move to the next value
  121. @owner
  122. -----------------------------------------------------------------------------*/
  123. VOID
  124. F::CRegEnumValues::operator++
  125. (
  126. int
  127. ) throw(CErr)
  128. {
  129. VSEE_ASSERT_CAN_THROW();
  130. ThrNext();
  131. }
  132. /*-----------------------------------------------------------------------------
  133. Name: CRegEnumValues::GetType
  134. @mfunc
  135. get the type of the current value
  136. @owner
  137. -----------------------------------------------------------------------------*/
  138. DWORD
  139. F::CRegEnumValues::GetType
  140. (
  141. ) const /*throw()*/
  142. {
  143. VSEE_NO_THROW();
  144. return m_dwType;
  145. }
  146. /*-----------------------------------------------------------------------------
  147. Name: CRegEnumValues::GetValuesCount
  148. @mfunc
  149. Returns the number of values under this key
  150. @owner AlinC
  151. -----------------------------------------------------------------------------*/
  152. DWORD
  153. F::CRegEnumValues::GetValuesCount
  154. (
  155. ) const /*throw()*/
  156. {
  157. VSEE_NO_THROW();
  158. return m_cValues;
  159. }
  160. /*-----------------------------------------------------------------------------
  161. Name: CRegEnumValues::GetValueName
  162. @mfunc
  163. get the name of the current value
  164. @owner
  165. -----------------------------------------------------------------------------*/
  166. const F::CBaseStringBuffer&
  167. F::CRegEnumValues::GetValueName
  168. (
  169. ) const /*throw()*/
  170. {
  171. VSEE_NO_THROW();
  172. return m_strValueName;
  173. }
  174. /*-----------------------------------------------------------------------------
  175. Name: CRegEnumValues::GetValueData
  176. @mfunc
  177. get the current value data
  178. @owner
  179. -----------------------------------------------------------------------------*/
  180. const BYTE*
  181. F::CRegEnumValues::GetValueData
  182. (
  183. ) const /*throw()*/
  184. {
  185. VSEE_NO_THROW();
  186. return m_rgbValueData.GetArrayPtr();
  187. }
  188. /*-----------------------------------------------------------------------------
  189. Name: CRegEnumValues::GetValueDataSize
  190. @mfunc
  191. get the number of bytes in the current value data
  192. @owner
  193. -----------------------------------------------------------------------------*/
  194. DWORD
  195. F::CRegEnumValues::GetValueDataSize
  196. (
  197. ) const /*throw()*/
  198. {
  199. VSEE_NO_THROW();
  200. return m_cbCurrentValueDataLength;
  201. }