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.

85 lines
2.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: regkey.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _REGKEY_H_
  11. #define _REGKEY_H_
  12. #include <assert.h>
  13. /////////////////////////////////////////////////////////////////////////////
  14. /////////////////////////////////////////////////////////////////////////////
  15. // REGKEY: Wrapper for a registry key
  16. /////////////////////////////////////////////////////////////////////////////
  17. /////////////////////////////////////////////////////////////////////////////
  18. class REGKEY
  19. {
  20. public:
  21. REGKEY() : m_hKey(NULL) {}
  22. ~ REGKEY() { Close(); }
  23. HKEY HKey () const { return m_hKey; }
  24. operator HKEY() const { return m_hKey; }
  25. LONG SetValue(DWORD dwValue, LPCTSTR lpszValueName);
  26. LONG QueryValue(DWORD& dwValue, LPCTSTR lpszValueName);
  27. LONG QueryValue(LPTSTR szValue, LPCTSTR lpszValueName, DWORD* pdwCount);
  28. LONG SetValue(LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL);
  29. LONG SetKeyValue( LPCTSTR lpszKeyName,
  30. LPCTSTR lpszValue,
  31. LPCTSTR lpszValueName = NULL);
  32. static LONG WINAPI SetValue( HKEY hKeyParent,
  33. LPCTSTR lpszKeyName,
  34. LPCTSTR lpszValue,
  35. LPCTSTR lpszValueName = NULL);
  36. LONG Create( HKEY hKeyParent,
  37. LPCTSTR lpszKeyName,
  38. LPTSTR lpszClass = REG_NONE,
  39. DWORD dwOptions = REG_OPTION_NON_VOLATILE,
  40. REGSAM samDesired = KEY_ALL_ACCESS,
  41. LPSECURITY_ATTRIBUTES lpSecAttr = NULL,
  42. LPDWORD lpdwDisposition = NULL);
  43. LONG Open( HKEY hKeyParent,
  44. LPCTSTR lpszKeyName,
  45. REGSAM samDesired = KEY_ALL_ACCESS);
  46. LONG Close();
  47. LONG RecurseDeleteKey(LPCTSTR lpszKey);
  48. void Attach(HKEY hKey);
  49. HKEY Detach()
  50. {
  51. HKEY hKey = m_hKey;
  52. m_hKey = NULL;
  53. return hKey;
  54. }
  55. LONG DeleteSubKey(LPCTSTR lpszSubKey)
  56. {
  57. assert(m_hKey != NULL);
  58. return RegDeleteKey(m_hKey, lpszSubKey);
  59. }
  60. LONG DeleteValue(LPCTSTR lpszValue)
  61. {
  62. assert(m_hKey != NULL);
  63. return RegDeleteValue(m_hKey, (LPTSTR)lpszValue);
  64. }
  65. protected:
  66. HKEY m_hKey;
  67. };
  68. #endif // _REGKEY_H_