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.

109 lines
3.7 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*--------------------------------------------------------------------------------------------------------
  3. *
  4. * Module Name:
  5. *
  6. * Registry.h
  7. *
  8. * Abstract:
  9. *
  10. * declaration of a simple registry class CRegistry.
  11. *
  12. *
  13. *
  14. * Author:
  15. *
  16. * Makarand Patwardhan - April 9, 1997
  17. *
  18. * -------------------------------------------------------------------------------------------------------*/
  19. #if !defined(AFX_REGISTRY_H__AA7047C5_B519_11D1_B05F_00C04FA35813__INCLUDED_)
  20. #define AFX_REGISTRY_H__AA7047C5_B519_11D1_B05F_00C04FA35813__INCLUDED_
  21. #if _MSC_VER >= 1000
  22. #pragma once
  23. #endif // _MSC_VER >= 1000
  24. #include <winreg.h>
  25. class CRegistry
  26. {
  27. private:
  28. LPBYTE m_pMemBlock;
  29. HKEY m_hKey;
  30. int m_iEnumIndex;
  31. int m_iEnumValueIndex;
  32. DWORD ReadReg (LPCTSTR lpValue, LPBYTE *lppbyte, DWORD *pdw, DWORD dwDatatype);
  33. void * Allocate (DWORD dwSize);
  34. //
  35. // This class is not designed to allow copy constructors, = assignments,
  36. // therefore we should ensure that copy ctor, assignment operator are not
  37. // generated by compiler. we do that by declaring these functions private
  38. // and not implementing them. This will ensure that these functions are
  39. // not generated by compilers, and caller will get error if he tries to
  40. // use them.
  41. //
  42. CRegistry (const CRegistry &reg); // copy ctor
  43. CRegistry & operator= (const CRegistry &reg); // = oprerator
  44. #ifdef DBG
  45. DWORD m_dwSizeDebugOnly;
  46. #endif
  47. public:
  48. CRegistry ();
  49. CRegistry (HKEY hKey);
  50. virtual ~CRegistry ();
  51. void Release ();
  52. operator HKEY () {return m_hKey;}
  53. DWORD OpenKey (HKEY hKey, LPCTSTR lpSubKey, REGSAM access = KEY_ALL_ACCESS, LPCTSTR lpMachineName = NULL);
  54. DWORD CreateKey (HKEY hKey, LPCTSTR lpSubKey, REGSAM access = KEY_ALL_ACCESS, DWORD *pDisposition = NULL, LPSECURITY_ATTRIBUTES lpSecAttr = NULL );
  55. DWORD DeleteValue (LPCTSTR lpValue);
  56. DWORD RecurseDeleteKey (LPCTSTR lpSubKey);
  57. DWORD CopyTree (CRegistry &regSrc);
  58. DWORD ReadRegString (LPCTSTR lpValue, LPTSTR *lppStr, DWORD *pdw);
  59. DWORD ReadRegDWord (LPCTSTR lpValue, DWORD *pdw);
  60. DWORD ReadRegMultiString (LPCTSTR lpValue, LPTSTR *lppStr, DWORD *pdw);
  61. DWORD ReadRegBinary (LPCTSTR lpValue, LPBYTE *lppByte, DWORD *pdw);
  62. DWORD WriteRegString (LPCTSTR lpValueName, LPCTSTR lpStr);
  63. DWORD WriteRegExString (LPCTSTR lpValueName, LPCTSTR lpStr);
  64. DWORD WriteRegDWord (LPCTSTR lpValueName, DWORD dwValue);
  65. DWORD WriteRegMultiString (LPCTSTR lpValueName, LPCTSTR lpStr, DWORD dwSize);
  66. DWORD WriteRegBinary (LPCTSTR lpValueName, LPBYTE lpData, DWORD dwSize);
  67. DWORD ExistInMultiString (LPCTSTR lpValueName, LPCTSTR lpCheckForStr, BOOL *pbExists);
  68. DWORD AppendToMultiString (LPCTSTR lpValueName, LPCTSTR lpStr);
  69. DWORD GetFirstSubKey (LPTSTR *lppStr, DWORD *pdw);
  70. DWORD GetNextSubKey (LPTSTR *lppStr, DWORD *pdw);
  71. DWORD GetFirstValue (LPTSTR *lppStr, DWORD *pdw, DWORD *pDataType);
  72. DWORD GetNextValue (LPTSTR *lppStr, DWORD *pdw, DWORD *pDataType);
  73. DWORD GetSecurity (PSECURITY_DESCRIPTOR *ppSec, SECURITY_INFORMATION SecurityInformation, DWORD *pdwSize);
  74. DWORD SetSecurity (PSECURITY_DESCRIPTOR pSec, SECURITY_INFORMATION SecurityInformation);
  75. };
  76. #endif // !defined(AFX_REGISTRY_H__AA7047C5_B519_11D1_B05F_00C04FA35813__INCLUDED_)
  77. //EOF