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.

130 lines
4.0 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. Registry.h
  5. Abstract:
  6. Class definition for the registry API wrapper class.
  7. Notes:
  8. ANSI & Unicode via TCHAR - runs on Win9x/NT/2K/XP etc.
  9. History:
  10. 01/29/2001 rparsons Created
  11. 03/02/2001 rparsons Major overhaul
  12. 01/27/2002 rparsons Converted to TCHAR
  13. --*/
  14. #ifndef _CREGISTRY_H
  15. #define _CREGISTRY_H
  16. #include <windows.h>
  17. #include <tchar.h>
  18. #include <strsafe.h>
  19. #define REG_FORCE_RESTORE (0x00000008L)
  20. //
  21. // Macro that returns TRUE if the given registry handle is predefined.
  22. //
  23. #define IsPredefinedRegistryHandle(h) \
  24. (( ( h == HKEY_CLASSES_ROOT ) \
  25. || ( h == HKEY_CURRENT_USER ) \
  26. || ( h == HKEY_LOCAL_MACHINE ) \
  27. || ( h == HKEY_USERS ) \
  28. || ( h == HKEY_CURRENT_CONFIG ) \
  29. || ( h == HKEY_PERFORMANCE_DATA ) \
  30. || ( h == HKEY_DYN_DATA )) \
  31. ? TRUE \
  32. : FALSE )
  33. class CRegistry {
  34. public:
  35. HKEY CreateKey(IN HKEY hKey,
  36. IN LPCTSTR pszSubKey,
  37. IN REGSAM samDesired);
  38. HKEY CreateKey(IN HKEY hKey,
  39. IN LPCTSTR pszSubKey,
  40. IN REGSAM samDesired,
  41. OUT LPDWORD pdwDisposition);
  42. LONG CloseKey(IN HKEY hKey);
  43. LPSTR GetString(IN HKEY hKey,
  44. IN LPCTSTR pszSubKey,
  45. IN LPCTSTR pszValueName);
  46. BOOL GetDword(IN HKEY hKey,
  47. IN LPCTSTR pszSubKey,
  48. IN LPCTSTR pszValueName,
  49. IN LPDWORD lpdwData);
  50. BOOL SetString(IN HKEY hKey,
  51. IN LPCTSTR pszSubKey,
  52. IN LPCTSTR pszValueName,
  53. IN LPCTSTR pszData);
  54. BOOL SetMultiSzString(IN HKEY hKey,
  55. IN LPCTSTR pszSubKey,
  56. IN LPCTSTR pszValueName,
  57. IN LPCTSTR pszData,
  58. IN DWORD cbSize);
  59. BOOL SetDword(IN HKEY hKey,
  60. IN LPCTSTR pszSubKey,
  61. IN LPCTSTR pszValueName,
  62. IN DWORD dwData);
  63. BOOL DeleteString(IN HKEY hKey,
  64. IN LPCTSTR pszSubKey,
  65. IN LPCTSTR pszValueName);
  66. BOOL IsRegistryKeyPresent(IN HKEY hKey,
  67. IN LPCTSTR pszSubKey);
  68. void Free(IN LPVOID pvMem);
  69. BOOL AddStringToMultiSz(IN HKEY hKey,
  70. IN LPCTSTR pszSubKey,
  71. IN LPCTSTR pszEntry);
  72. BOOL RemoveStringFromMultiSz(IN HKEY hKey,
  73. IN LPCTSTR pszSubKey,
  74. IN LPCTSTR pszEntry);
  75. BOOL RestoreKey(IN HKEY hKey,
  76. IN LPCTSTR pszSubKey,
  77. IN LPCTSTR pszFileName,
  78. IN BOOL fGrantPrivs);
  79. BOOL BackupRegistryKey(IN HKEY hKey,
  80. IN LPCTSTR pszSubKey,
  81. IN LPCTSTR pszFileName,
  82. IN BOOL fGrantPrivs);
  83. private:
  84. DWORD GetStringSize(IN HKEY hKey,
  85. IN LPCTSTR pszValueName,
  86. IN OUT LPDWORD lpType OPTIONAL);
  87. LPVOID Malloc(IN SIZE_T cbBytes);
  88. HKEY OpenKey(IN HKEY hKey,
  89. IN LPCTSTR pszSubKey,
  90. IN REGSAM samDesired);
  91. int ListStoreLen(IN LPTSTR pszList);
  92. BOOL ModifyTokenPrivilege(IN LPCTSTR pszPrivilege,
  93. IN BOOL fEnable);
  94. };
  95. #endif // _CREGISTRY_H