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.

179 lines
3.6 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. Registry
  5. Abstract:
  6. This header file defines a class to provide simple interaction to values in
  7. the Registry Database.
  8. Author:
  9. Doug Barlow (dbarlow) 7/15/1996
  10. Environment:
  11. Win32, C++ w/ Exceptions
  12. Notes:
  13. --*/
  14. #ifndef _REGISTRY_H_
  15. #define _REGISTRY_H_
  16. #include <winreg.h>
  17. #define REG_OPTION_EXISTS (~REG_LEGAL_OPTION)
  18. //
  19. //==============================================================================
  20. //
  21. // CRegistry
  22. //
  23. class CRegistry
  24. {
  25. public:
  26. // Constructors & Destructor
  27. CRegistry(
  28. HKEY hBase,
  29. LPCTSTR szName,
  30. REGSAM samDesired = KEY_ALL_ACCESS,
  31. DWORD dwOptions = REG_OPTION_EXISTS,
  32. LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL);
  33. CRegistry(void);
  34. ~CRegistry();
  35. // Properties
  36. // Methods
  37. void
  38. Open(
  39. HKEY hBase,
  40. LPCTSTR szName,
  41. REGSAM samDesired = KEY_ALL_ACCESS,
  42. DWORD dwOptions = REG_OPTION_EXISTS,
  43. LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL);
  44. void Close(void);
  45. LONG Status(BOOL fQuiet = FALSE) const;
  46. void Empty(void);
  47. void Copy(CRegistry &regSrc);
  48. void DeleteKey(LPCTSTR szKey, BOOL fQuiet = FALSE) const;
  49. void DeleteValue(LPCTSTR szValue, BOOL fQuiet = FALSE) const;
  50. LPCTSTR Subkey(DWORD dwIndex);
  51. LPCTSTR Value(DWORD dwIndex, LPDWORD pdwType = NULL);
  52. void
  53. GetValue(
  54. LPCTSTR szKeyValue,
  55. LPTSTR *pszValue,
  56. LPDWORD pdwType = NULL);
  57. void
  58. GetValue(
  59. LPCTSTR szKeyValue,
  60. LPDWORD pdwValue,
  61. LPDWORD pdwType = NULL)
  62. const;
  63. void
  64. GetValue(
  65. LPCTSTR szKeyValue,
  66. LPBYTE *ppbValue,
  67. LPDWORD pcbLength,
  68. LPDWORD pdwType = NULL);
  69. void
  70. GetValue(
  71. LPCTSTR szKeyValue,
  72. CBuffer &bfValue,
  73. LPDWORD pdwType = NULL);
  74. void
  75. SetValue(
  76. LPCTSTR szKeyValue,
  77. LPCTSTR szValue,
  78. DWORD dwType = REG_SZ)
  79. const;
  80. void
  81. SetValue(
  82. LPCTSTR szKeyValue,
  83. DWORD dwValue,
  84. DWORD dwType = REG_DWORD)
  85. const;
  86. void
  87. SetValue(
  88. LPCTSTR szKeyValue,
  89. LPCBYTE pbValue,
  90. DWORD cbLength,
  91. DWORD dwType = REG_BINARY)
  92. const;
  93. void
  94. SetAcls(
  95. IN SECURITY_INFORMATION SecurityInformation,
  96. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  97. IN BOOL fRecurse = TRUE);
  98. void
  99. SetMultiStringValue(
  100. LPCTSTR szKeyValue,
  101. LPCTSTR mszValue,
  102. DWORD dwType = REG_MULTI_SZ)
  103. const;
  104. LPCTSTR
  105. GetStringValue(
  106. LPCTSTR szKeyValue,
  107. LPDWORD pdwType = NULL);
  108. DWORD
  109. GetNumericValue(
  110. LPCTSTR szKeyValue,
  111. LPDWORD pdwType = NULL)
  112. const;
  113. LPCBYTE
  114. GetBinaryValue(
  115. LPCTSTR szKeyValue,
  116. LPDWORD pcbLength = NULL,
  117. LPDWORD pdwType = NULL);
  118. LPCTSTR
  119. GetMultiStringValue(
  120. LPCTSTR szKeyValue,
  121. LPDWORD pdwType = NULL);
  122. DWORD
  123. GetValueLength(
  124. void)
  125. const;
  126. BOOL
  127. ValueExists(
  128. LPCTSTR szKeyValue,
  129. LPDWORD pcbLength = NULL,
  130. LPDWORD pdwType = NULL)
  131. const;
  132. DWORD
  133. GetDisposition(
  134. void)
  135. const;
  136. // Operators
  137. operator HKEY(
  138. void)
  139. const
  140. { Status();
  141. return m_hKey; };
  142. protected:
  143. // Properties
  144. HKEY m_hKey;
  145. DWORD m_dwDisposition;
  146. CBuffer m_bfResult;
  147. LONG m_lSts;
  148. // Methods
  149. };
  150. #endif // _REGISTRY_H_