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.

76 lines
2.5 KiB

  1. //
  2. // MODULE: "RegUtil.h"
  3. //
  4. // PURPOSE: class CRegUtil
  5. // Encapsulates access to system registry.
  6. // This is intended as generic access to the registry, independent of any particular
  7. // application.
  8. //
  9. // PROJECT: first developed as part of Belief Network Editing Tools ("Argon")
  10. // Later modified to provide more extensive features as part of version 3.0 of the
  11. // Online Troubleshooter (APGTS)
  12. //
  13. // AUTHOR: Lonnie Gerrald (LDG), Oleg Kalosha, Joe Mabel
  14. //
  15. // ORIGINAL DATE: 3/25/98
  16. //
  17. // NOTES:
  18. // 1.
  19. //
  20. // Version Date By Comments
  21. //--------------------------------------------------------------------
  22. // V0.1(Argon) 3/25/98 LDG
  23. // V3.0 8/??/98 OK
  24. // V3.0 9/9/98 JM
  25. #include <vector>
  26. #include <algorithm>
  27. using namespace std;
  28. #include "apgtsstr.h"
  29. //////////////////////////////////////////////////////////////////////
  30. // CRegUtil
  31. // class for accessing registry
  32. // NOT multithreaded!
  33. //////////////////////////////////////////////////////////////////////
  34. class CRegUtil
  35. {
  36. private:
  37. long m_WinError; // windows error listed in WINERROR.H file
  38. HKEY m_hKey; // current key handle
  39. vector<HKEY> m_arrKeysToClose; // array of keys(subkeys) opened by the object
  40. private:
  41. CRegUtil(const CRegUtil&) {} // prohibit copying since it is confusing:
  42. // one object can close handlers being used by another
  43. public:
  44. CRegUtil();
  45. explicit CRegUtil(HKEY);
  46. virtual ~CRegUtil();
  47. operator HKEY() const {return m_hKey;}
  48. long GetResult() const {return m_WinError;}
  49. // major operations
  50. bool Create(HKEY hKeyParent, const CString& strKeyName, bool* bCreatedNew, REGSAM access =KEY_ALL_ACCESS);
  51. bool Open(HKEY hKeyParent, const CString& strKeyName, REGSAM access =KEY_ALL_ACCESS);
  52. bool Create(const CString& strKeyName, bool* bCreatedNew, REGSAM access =KEY_ALL_ACCESS); // migrate "this" to subkey
  53. bool Open(const CString& strKeyName, REGSAM access =KEY_ALL_ACCESS); // migrate "this" to subkey
  54. void Close();
  55. // sub key manipulation
  56. bool DeleteSubKey(const CString& strSubKey);
  57. bool DeleteValue(const CString& strValue);
  58. // set value
  59. bool SetNumericValue(const CString& strValueName, DWORD dwValue);
  60. bool SetStringValue(const CString& strValueName, const CString& strValue);
  61. bool SetBinaryValue(const CString& strValueName, char* buf, long buf_len);
  62. // get value
  63. bool GetNumericValue(const CString& strValueName, DWORD& dwValue);
  64. bool GetStringValue(const CString& strValueName, CString& strValue);
  65. bool GetBinaryValue(const CString& strValueName, char** buf, long* buf_len);
  66. };