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.

136 lines
3.4 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1997 **/
  4. /**********************************************************************/
  5. /*
  6. registry.hxx
  7. This module contains definitions for registry classes.
  8. FILE HISTORY:
  9. 7/7/97 michth ported from metadata.
  10. */
  11. #ifndef _registry_h
  12. #define _registry_h
  13. // Forward declarations
  14. class MDRegKey ;
  15. class MDRegValueIter ;
  16. class MDRegKeyIter ;
  17. // Maximum size of a Registry class name
  18. #define MDREGKEY_MAX_CLASS_NAME MAX_PATH
  19. // Wrapper for a Registry key handle.
  20. class MDRegKey
  21. {
  22. protected:
  23. HKEY m_hKey ;
  24. DWORD m_dwDisposition ;
  25. public:
  26. // Key information return structure
  27. typedef struct
  28. {
  29. TCHAR chBuff [MDREGKEY_MAX_CLASS_NAME] ;
  30. DWORD dwClassNameSize,
  31. dwNumSubKeys,
  32. dwMaxSubKey,
  33. dwMaxClass,
  34. dwMaxValues,
  35. dwMaxValueName,
  36. dwMaxValueData,
  37. dwSecDesc ;
  38. FILETIME ftKey ;
  39. } MDREGKEY_KEY_INFO ;
  40. // Standard constructor for an existing key
  41. MDRegKey ( HKEY hKeyBase,
  42. const TCHAR * pchSubKey = NULL,
  43. REGSAM regSam = KEY_ALL_ACCESS,
  44. const TCHAR * pchServerName = NULL ) ;
  45. // Constructor creating a new key.
  46. MDRegKey ( const TCHAR * pchSubKey,
  47. HKEY hKeyBase,
  48. DWORD dwOptions = 0,
  49. REGSAM regSam = KEY_ALL_ACCESS,
  50. LPSECURITY_ATTRIBUTES pSecAttr = NULL,
  51. const TCHAR * pchServerName = NULL ) ;
  52. ~ MDRegKey () ;
  53. // Allow a MDRegKey to be used anywhere an HKEY is required.
  54. operator HKEY ()
  55. { return m_hKey ; }
  56. // Fill a key information structure
  57. DWORD QueryKeyInfo ( MDREGKEY_KEY_INFO * pRegKeyInfo ) ;
  58. // Overloaded value query members; each returns ERROR_INVALID_PARAMETER
  59. // if data exists but not in correct form to deliver into result object.
  60. DWORD QueryValue (LPTSTR pchValueName,
  61. DWORD * pdwType,
  62. DWORD * pdwSize,
  63. BUFFER *pbufData );
  64. // Overloaded value setting members.
  65. DWORD SetValue (LPCTSTR pchValueName,
  66. DWORD dwType,
  67. DWORD dwSize,
  68. PBYTE pbData);
  69. DWORD
  70. DeleteValue (LPCTSTR pchValueName);
  71. };
  72. // Iterate the values of a key, return the name and type
  73. // of each.
  74. class MDRegValueIter
  75. {
  76. protected:
  77. MDRegKey & m_rk_iter ;
  78. DWORD m_dw_index ;
  79. TCHAR * m_p_buffer ;
  80. DWORD m_cb_buffer ;
  81. public:
  82. MDRegValueIter ( MDRegKey &regKey );
  83. ~ MDRegValueIter () ;
  84. // Get the name (and optional last write time) of the next key.
  85. DWORD Next ( LPTSTR * ppszName, DWORD * pdwType);
  86. // Reset the iterator
  87. void Reset ()
  88. { m_dw_index = 0 ; }
  89. };
  90. // Iterate the sub-key names of a key.
  91. class MDRegKeyIter
  92. {
  93. protected:
  94. MDRegKey & m_rk_iter ;
  95. DWORD m_dw_index ;
  96. TCHAR * m_p_buffer ;
  97. DWORD m_cb_buffer ;
  98. public:
  99. MDRegKeyIter ( MDRegKey & regKey ) ;
  100. ~ MDRegKeyIter () ;
  101. // Get the name (and optional last write time) of the next key.
  102. DWORD Next ( LPTSTR *ppszName, FILETIME *pTime = NULL, DWORD dwIndex = 0xffffffff);
  103. // Reset the iterator
  104. void Reset ()
  105. { m_dw_index = 0 ; }
  106. };
  107. #endif
  108.