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.

88 lines
2.8 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: creg.h
  6. * Content: definition of the CRegistry class
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 07/16/99 rodtoll Created
  12. * 08/18/99 rodtoll Added Register/UnRegister that can be used to
  13. * allow COM objects to register themselves.
  14. * 08/25/99 rodtoll Updated to provide read/write of binary (blob) data
  15. * 10/07/99 rodtoll Updated to work in Unicode
  16. * 10/27/99 pnewson added Open() call that takes a GUID
  17. *
  18. ***************************************************************************/
  19. #ifndef __CREGISTRY_H
  20. #define __CREGISTRY_H
  21. #include <mmsystem.h>
  22. #include <mmreg.h>
  23. #include <msacm.h>
  24. // Useful definition
  25. #define MAX_REGISTRY_STRING_SIZE _MAX_PATH+1
  26. // CRegistry
  27. //
  28. // This class handles reading/writing to the windows registry. Each instance
  29. // of the CRegistry class is attached to a single registry handle, which is
  30. // an open handle to a point in the registry tree.
  31. //
  32. class CRegistry
  33. {
  34. public:
  35. CRegistry();
  36. CRegistry( const CRegistry &registry );
  37. CRegistry( const HKEY branch, LPWSTR pathName, BOOL create = TRUE );
  38. ~CRegistry();
  39. BOOL EnumKeys( LPWSTR lpwStrName, LPDWORD lpdwStringLen, DWORD index = 0 );
  40. BOOL Open( const HKEY branch, const LPCWSTR pathName, BOOL create = TRUE );
  41. BOOL Open( const HKEY branch, const GUID* lpguid, BOOL create = TRUE );
  42. BOOL Close();
  43. BOOL IsOpen() { return m_isOpen; };
  44. BOOL DeleteSubKey( LPCWSTR keyName );
  45. BOOL ReadGUID( LPCWSTR keyName, GUID &guid );
  46. BOOL WriteGUID( LPCWSTR keyName, const GUID &guid );
  47. BOOL WriteString( LPCWSTR keyName, const LPCWSTR lpwstrValue );
  48. BOOL ReadString( LPCWSTR keyName, LPWSTR lpwstrValue, LPDWORD lpdwLength );
  49. BOOL WriteDWORD( LPCWSTR keyName, DWORD value );
  50. BOOL ReadDWORD( LPCWSTR keyName, DWORD &result );
  51. BOOL WriteBOOL( LPCWSTR keyName, BOOL value );
  52. BOOL ReadBOOL( LPCWSTR keyName, BOOL &result );
  53. BOOL ReadBlob( LPCWSTR keyName, LPBYTE lpbBuffer, LPDWORD lpdwSize );
  54. BOOL WriteBlob( LPCWSTR keyName, LPBYTE lpbBuffer, DWORD dwSize );
  55. static BOOL Register( LPCWSTR lpszProgID, LPCWSTR lpszDesc, LPCWSTR lpszProgName, GUID guidCLSID, LPCWSTR lpszVerIndProgID );
  56. static BOOL UnRegister( GUID guidCLSID );
  57. // Data access functions
  58. operator HKEY() const { return m_regHandle; };
  59. HKEY GetBaseHandle() const { return m_baseHandle; };
  60. HKEY GetHandle() const { return m_regHandle; };
  61. protected:
  62. BOOL m_isOpen; // BOOL indicating if the object is open
  63. HKEY m_regHandle; // Handle to the registry which is represented by this object
  64. HKEY m_baseHandle; // Handle to the root of the part of the registry
  65. // this object is in. E.g. HKEY_LOCAL_MACHINE
  66. };
  67. #endif