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.

88 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 _EnterCSKeyRoot();
  49. void _LeaveCSKeyRoot();
  50. virtual LPCTSTR _GetRoot(LPTSTR pszRoot, DWORD cchRoot);
  51. protected:
  52. LPCTSTR _pszSubKey1;
  53. LPCTSTR _pszSubKey2;
  54. private:
  55. DWORD _dwRootOptions;
  56. DWORD _dwDefaultOptions;
  57. HKEY _hkeyInit; // HKEY_CURRENT_USER, ...
  58. CRITICAL_SECTION _csKeyRoot;
  59. BOOL _fcsKeyRoot;
  60. #ifdef DEBUG
  61. static UINT _cRefHKEY;
  62. static UINT _cRefExternalHKEY;
  63. BOOL _fInited;
  64. #endif
  65. };
  66. #endif //__REGSUPRT_H