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
3.8 KiB

  1. //****************************************************************************
  2. //
  3. // Copyright (c) 1995, Microsoft Corp.
  4. //
  5. // File: REGKEY.H
  6. //
  7. // Definitions for registry management classes
  8. //
  9. // History:
  10. // Scott V. Walker, SEA 10/5/94
  11. //
  12. //****************************************************************************
  13. #ifndef _REGKEY_H_
  14. #define _REGKEY_H_
  15. #include <tchar.h>
  16. //****************************************************************************
  17. //
  18. // CLASS: CRegistryValue
  19. //
  20. //****************************************************************************
  21. class CRegistryValue : public CObject
  22. {
  23. DECLARE_DYNAMIC(CRegistryValue)
  24. public:
  25. CString m_sName;
  26. DWORD m_dwType;
  27. DWORD m_dwDataLength;
  28. LPBYTE m_pData;
  29. public:
  30. CRegistryValue();
  31. CRegistryValue(LPCTSTR pszName, DWORD dwType, DWORD dwDataLength,
  32. LPBYTE pData);
  33. ~CRegistryValue();
  34. void Set(LPCTSTR pszName, DWORD dwType, DWORD dwDataLength,
  35. LPBYTE pData);
  36. void Get(CString &sName, DWORD &dwType, DWORD &dwDataLength,
  37. LPBYTE pData = NULL);
  38. void Empty();
  39. const CRegistryValue& operator=(CRegistryValue &other);
  40. };
  41. //****************************************************************************
  42. //
  43. // CLASS: CRegistryKey
  44. //
  45. //****************************************************************************
  46. class CRegistryKey : public CObject
  47. {
  48. DECLARE_DYNAMIC(CRegistryKey)
  49. public:
  50. CString m_sComputer; // Name of computer we're connected to
  51. HKEY m_hkeyConnect; // Handle to current connection key (or NULL)
  52. HKEY m_hkeyRemote; // Handle to remote connection key (or NULL)
  53. BOOL m_bConnected; // TRUE if currently connected
  54. BOOL m_bLocal; // TRUE if connected to the local computer
  55. HKEY m_hkeyOpen; // Handle to currently open key (or NULL)
  56. BOOL m_bOpen; // TRUE if currently open
  57. CString m_sFullName; // Full path name of currently open key
  58. CString m_sKeyName; // Name of currently open key
  59. REGSAM m_Sam; // Security access mask we opened with
  60. BOOL m_bDirty; // TRUE if there are changes pending in this key
  61. CString m_sClass; // Class name of key
  62. DWORD m_dwSubKeys; // Number of subkeys in this key
  63. DWORD m_dwMaxSubKey; // Longest subkey name length
  64. DWORD m_dwMaxClass; // Longest class string length
  65. DWORD m_dwValues; // Number of value entries in current key
  66. DWORD m_dwMaxValueName; // Longest value name length
  67. DWORD m_dwMaxValueData; // Longest value data length
  68. DWORD m_dwSecurityDescriptor; // Security descriptor length
  69. FILETIME m_ftLastWriteTime; // Last modification date for key or values
  70. LONG m_lResult; // Last return value from a registry API
  71. public:
  72. CRegistryKey();
  73. ~CRegistryKey();
  74. void Initialize();
  75. LONG Connect(LPCTSTR pszComputer = NULL,
  76. HKEY hkey = HKEY_LOCAL_MACHINE);
  77. LONG Disconnect(BOOL bForce = FALSE);
  78. LONG Open(LPCTSTR pszKeyName, REGSAM samDesired = KEY_ALL_ACCESS);
  79. LONG Create(LPCTSTR pszKeyName, DWORD &dwDisposition,
  80. LPCTSTR pszClass = NULL, REGSAM samDesired = KEY_ALL_ACCESS,
  81. LPSECURITY_ATTRIBUTES lpSecAttr = NULL);
  82. LONG Close(BOOL bForce = FALSE);
  83. CStringArray* EnumValues();
  84. CStringArray* EnumSubKeys();
  85. BOOL GetValue(LPCTSTR pszValue, CRegistryValue &regval);
  86. BOOL SetValue(CRegistryValue &regval);
  87. BOOL GetSubKey(LPCTSTR pszSubKey, CRegistryKey &regkey);
  88. BOOL CreateSubKey(LPCTSTR pszSubKey, CRegistryKey &regkey,
  89. LPCTSTR pszClass = NULL, LPSECURITY_ATTRIBUTES lpSecAttr = NULL, BOOL bIsVolatile = FALSE);
  90. BOOL DeleteSubKey(LPCTSTR pszSubKey);
  91. };
  92. class CEventTrapRegistry
  93. {
  94. public:
  95. CEventTrapRegistry();
  96. ~CEventTrapRegistry();
  97. };
  98. extern BOOL g_bLostConnection;
  99. #endif // _REGKEY_H_