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.

120 lines
1.9 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1997.
  5. //
  6. // File: safereg.hxx
  7. //
  8. // Contents: C++ wrapper for registry APIs, works like safe pointer
  9. //
  10. // Classes: CSafeReg
  11. //
  12. // History: 1-02-1997 DavidMun Created
  13. //
  14. //---------------------------------------------------------------------------
  15. #ifndef __SAFEREG_HXX_
  16. #define __SAFEREG_HXX_
  17. class CSafeReg
  18. {
  19. public:
  20. CSafeReg();
  21. ~CSafeReg();
  22. operator HKEY() const;
  23. HRESULT
  24. Open(
  25. HKEY hKeyParent,
  26. LPCTSTR lpszKeyName,
  27. REGSAM samDesired);
  28. VOID
  29. Close();
  30. HRESULT
  31. Connect(
  32. LPCWSTR pwszMachineName,
  33. HKEY hkeyPredefined);
  34. HRESULT
  35. Create(
  36. LPCWSTR wszSubKey,
  37. CSafeReg *pshkNew);
  38. HRESULT
  39. DeleteTree(
  40. LPCWSTR wszSubKey);
  41. HRESULT
  42. DeleteValue(
  43. LPCWSTR wszValueName);
  44. HRESULT
  45. Enum(
  46. ULONG ulSubKey,
  47. LPWSTR pwszSubkeyName,
  48. ULONG cchSubkeyName);
  49. HRESULT
  50. QueryBufSize(
  51. LPWSTR wszValueName,
  52. ULONG *pcb);
  53. HRESULT
  54. QueryDword(
  55. LPWSTR wszValueName,
  56. LPDWORD pdw);
  57. HRESULT
  58. QueryPath(
  59. LPWSTR pwszValueName,
  60. LPWSTR pwszBuf,
  61. ULONG cchPathBuf,
  62. BOOL fExpand);
  63. HRESULT
  64. QueryStr(
  65. LPWSTR pwszValueName,
  66. LPWSTR pwszBuf,
  67. ULONG cchBuf);
  68. HRESULT
  69. SetDword(
  70. LPWSTR wszValueName,
  71. DWORD dw);
  72. HRESULT
  73. SetValue(
  74. LPCWSTR wszValueName,
  75. ULONG ulType,
  76. const BYTE *pbValue,
  77. ULONG cbValue);
  78. private:
  79. HKEY _hKey;
  80. };
  81. inline
  82. CSafeReg::CSafeReg():
  83. _hKey(NULL)
  84. {
  85. }
  86. inline
  87. CSafeReg::~CSafeReg()
  88. {
  89. Close();
  90. }
  91. inline
  92. CSafeReg::operator HKEY() const
  93. {
  94. return _hKey;
  95. }
  96. #endif // __SAFEREG_HXX_