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.

89 lines
3.0 KiB

  1. #ifndef __REGSUPRT_H
  2. #define __REGSUPRT_H
  3. #define REG_OPTION_INVALID 0xFFFFFFFF
  4. // MAX_ROOT is the maximum we support for the root
  5. #define MAX_ROOT MAX_PATH
  6. class CRegSupport
  7. {
  8. public:
  9. CRegSupport();
  10. virtual ~CRegSupport();
  11. public:
  12. void RSInitRoot(HKEY hkey, LPCTSTR pszSubKey1, LPCTSTR pszSubKey2,
  13. DWORD dwRootOptions = REG_OPTION_VOLATILE,
  14. DWORD dwDefaultOptions = REG_OPTION_VOLATILE);
  15. virtual BOOL RSValueExist(LPCTSTR pszSubKey, LPCTSTR pszValueName);
  16. virtual BOOL RSSubKeyExist(LPCTSTR pszSubKey);
  17. virtual BOOL RSDeleteValue(LPCTSTR pszSubKey, LPCTSTR pszValueName);
  18. virtual BOOL RSDeleteSubKey(LPCTSTR pszSubKey);
  19. virtual BOOL RSDeleteKey();
  20. virtual HKEY RSDuplicateRootKey();
  21. virtual HKEY RSDuplicateSubKey(LPCTSTR pszSubKey, BOOL fCreate, BOOL fVolatile);
  22. BOOL RSGetTextValue(LPCTSTR pszSubKey, LPCTSTR pszValueName,
  23. LPTSTR pszValue, DWORD* pcchValue);
  24. BOOL RSGetBinaryValue(LPCTSTR pszSubKey, LPCTSTR pszValueName,
  25. PBYTE pb, DWORD* pcb);
  26. BOOL RSGetDWORDValue(LPCTSTR pszSubKey, LPCTSTR pszValueName, DWORD* pdwValue);
  27. BOOL RSSetTextValue(LPCTSTR pszSubKey, LPCTSTR pszValueName, LPCTSTR pszValue,
  28. DWORD dwOptions = REG_OPTION_INVALID);
  29. BOOL RSSetBinaryValue(LPCTSTR pszSubKey, LPCTSTR pszValueName, PBYTE pb, DWORD cb,
  30. DWORD dwOptions = REG_OPTION_INVALID);
  31. BOOL RSSetDWORDValue(LPCTSTR pszSubKey, LPCTSTR pszValueName, DWORD dwValue,
  32. DWORD dwOptions = REG_OPTION_INVALID);
  33. protected:
  34. virtual void _CloseRegSubKey(HKEY hkeyVolumeSubKey);
  35. virtual HKEY _GetRootKey(BOOL fCreate, DWORD dwOptions = REG_OPTION_INVALID);
  36. virtual BOOL _SetGeneric(LPCTSTR pszSubKey, LPCTSTR pszValueName,
  37. PBYTE pb, DWORD cb, DWORD dwType,
  38. DWORD dwOptions);
  39. virtual BOOL _GetGeneric(LPCTSTR pszSubKey, LPCTSTR pszValueName,
  40. PBYTE pb, DWORD* pcb);
  41. HKEY _GetSubKey(LPCTSTR pszSubKey, BOOL fCreate,
  42. DWORD dwOptions = REG_OPTION_INVALID);
  43. static HKEY _RegCreateKeyExHelper(HKEY hkey, LPCTSTR pszSubKey,
  44. DWORD dwOptions);
  45. static HKEY _RegOpenKeyExHelper(HKEY hkey, LPCTSTR pszSubKey);
  46. protected:
  47. virtual BOOL _InitSetRoot(LPCTSTR pszSubKey1, LPCTSTR pszSubKey2);
  48. void _InitCSKeyRoot();
  49. void _EnterCSKeyRoot();
  50. void _LeaveCSKeyRoot();
  51. virtual LPCTSTR _GetRoot(LPTSTR pszRoot, DWORD cchRoot);
  52. protected:
  53. LPCTSTR _pszSubKey1;
  54. LPCTSTR _pszSubKey2;
  55. private:
  56. DWORD _dwRootOptions;
  57. DWORD _dwDefaultOptions;
  58. HKEY _hkeyInit; // HKEY_CURRENT_USER, ...
  59. CRITICAL_SECTION _csKeyRoot;
  60. BOOL _fcsKeyRoot;
  61. #ifdef DEBUG
  62. static UINT _cRefHKEY;
  63. static UINT _cRefExternalHKEY;
  64. BOOL _fInited;
  65. #endif
  66. };
  67. #endif //__REGSUPRT_H