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.

124 lines
3.0 KiB

  1. #ifndef _INC_DSKQUOTA_REGISTRY_H
  2. #define _INC_DSKQUOTA_REGISTRY_H
  3. #ifndef _WINDOWS_
  4. # include <windows.h>
  5. #endif
  6. #ifndef _INC_DSKQUOTA_STRCLASS_H
  7. # include "strclass.h"
  8. #endif
  9. #ifndef _INC_DSKQUOTA_CARRAY_H
  10. # include "carray.h"
  11. #endif
  12. //
  13. // Represents a single registry key. Provides basic functions for
  14. // opening and closing the key as well as setting and querying for
  15. // values in that key. Closure of the key handle is ensured through
  16. // the destructor.
  17. //
  18. class RegKey
  19. {
  20. public:
  21. RegKey(void);
  22. RegKey(HKEY hkeyRoot, LPCTSTR pszSubKey);
  23. virtual ~RegKey(void);
  24. operator HKEY(void) const
  25. { return m_hkey; }
  26. HKEY GetHandle(void) const
  27. { return m_hkey; }
  28. HRESULT Open(REGSAM samDesired, bool bCreate = false) const;
  29. void Attach(HKEY hkey);
  30. void Detach(void);
  31. void Close(void) const;
  32. int GetValueBufferSize(
  33. LPCTSTR pszValueName) const;
  34. bool IsOpen(void) const
  35. { return NULL != m_hkey; }
  36. //
  37. // Retrieve REG_DWORD
  38. //
  39. HRESULT GetValue(
  40. LPCTSTR pszValueName,
  41. DWORD *pdwDataOut) const;
  42. //
  43. // Retrieve REG_BINARY
  44. //
  45. HRESULT GetValue(
  46. LPCTSTR pszValueName,
  47. LPBYTE pbDataOut,
  48. int cbDataOut) const;
  49. //
  50. // Retrieve REG_SZ
  51. //
  52. HRESULT GetValue(
  53. LPCTSTR pszValueName,
  54. CString *pstrDataOut) const;
  55. //
  56. // Retrieve REG_MULTI_SZ
  57. //
  58. HRESULT GetValue(
  59. LPCTSTR pszValueName,
  60. CArray<CString> *prgstrOut) const;
  61. //
  62. // Set REG_DWORD
  63. //
  64. HRESULT SetValue(
  65. LPCTSTR pszValueName,
  66. DWORD dwData);
  67. //
  68. // Set REG_BINARY
  69. //
  70. HRESULT SetValue(
  71. LPCTSTR pszValueName,
  72. const LPBYTE pbData,
  73. int cbData);
  74. //
  75. // Set REG_SZ
  76. //
  77. HRESULT SetValue(
  78. LPCTSTR pszValueName,
  79. LPCTSTR pszData);
  80. //
  81. // Set REG_MULTI_SZ
  82. //
  83. HRESULT SetValue(
  84. LPCTSTR pszValueName,
  85. const CArray<CString>& rgstrData);
  86. private:
  87. HKEY m_hkeyRoot;
  88. mutable HKEY m_hkey;
  89. CString m_strSubKey;
  90. HRESULT SetValue(
  91. LPCTSTR pszValueName,
  92. DWORD dwValueType,
  93. const LPBYTE pbData,
  94. int cbData);
  95. HRESULT GetValue(
  96. LPCTSTR pszValueName,
  97. DWORD dwTypeExpected,
  98. LPBYTE pbData,
  99. int cbData) const;
  100. LPTSTR CreateDoubleNulTermList(
  101. const CArray<CString>& rgstrSrc) const;
  102. //
  103. // Prevent copy.
  104. //
  105. RegKey(const RegKey& rhs);
  106. RegKey& operator = (const RegKey& rhs);
  107. };
  108. #endif // _INC_DSKQUOTA_REGISTRY_H