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.

112 lines
1.9 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1998.
  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. Enum(
  40. ULONG ulSubKey,
  41. LPWSTR pwszSubkeyName,
  42. ULONG cchSubkeyName);
  43. HRESULT
  44. QueryBufSize(
  45. LPWSTR wszValueName,
  46. ULONG *pcb);
  47. HRESULT
  48. QueryDword(
  49. LPWSTR wszValueName,
  50. LPDWORD pdw);
  51. HRESULT
  52. QueryPath(
  53. LPWSTR pwszValueName,
  54. LPWSTR pwszBuf,
  55. ULONG cchPathBuf,
  56. BOOL fExpand);
  57. HRESULT
  58. QueryStr(
  59. LPWSTR pwszValueName,
  60. LPWSTR pwszBuf,
  61. ULONG cchBuf);
  62. HRESULT
  63. SetDword(
  64. LPWSTR wszValueName,
  65. DWORD dw);
  66. HRESULT
  67. SetValue(
  68. LPCWSTR wszValueName,
  69. ULONG ulType,
  70. const BYTE *pbValue,
  71. ULONG cbValue);
  72. private:
  73. HKEY _hKey;
  74. };
  75. inline
  76. CSafeReg::CSafeReg():
  77. _hKey(NULL)
  78. {
  79. }
  80. inline
  81. CSafeReg::~CSafeReg()
  82. {
  83. Close();
  84. }
  85. inline
  86. CSafeReg::operator HKEY() const
  87. {
  88. return _hKey;
  89. }
  90. #endif // __SAFEREG_HXX_