Leaked source code of windows server 2003
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.

74 lines
3.6 KiB

  1. //#pragma title( "TReg.hpp - Registry class" )
  2. /*
  3. Copyright (c) 1995-1998, Mission Critical Software, Inc. All rights reserved.
  4. ===============================================================================
  5. Module - TReg.hpp
  6. System - Common
  7. Author - Tom Bernhardt, Rich Denham, Jay Berlin
  8. Created - 1995-09-01
  9. Description - Registry class.
  10. Updates -
  11. ===============================================================================
  12. */
  13. #ifndef MCSINC_TReg_hpp
  14. #define MCSINC_TReg_hpp
  15. class TRegKey
  16. {
  17. private:
  18. HKEY hKey;
  19. public:
  20. TRegKey() { hKey = (HKEY)INVALID_HANDLE_VALUE; };
  21. TRegKey( HKEY hPreDefined, TCHAR const * machineName ) : hKey((HKEY)INVALID_HANDLE_VALUE) { Connect( hPreDefined, machineName ); };
  22. TRegKey( TCHAR const * keyname, HKEY hParent = (HKEY)HKEY_LOCAL_MACHINE ) : hKey((HKEY)INVALID_HANDLE_VALUE) { Open( keyname, hParent ); };
  23. TRegKey( TCHAR const * keyname, TRegKey const * regParent ) : hKey((HKEY)INVALID_HANDLE_VALUE) { Open( keyname, regParent->hKey ); };
  24. ~TRegKey();
  25. DWORD Connect( HKEY hPreDefined, TCHAR const * machineName );
  26. DWORD Open( TCHAR const * keyname, TRegKey const * regParent, DWORD access = KEY_ALL_ACCESS ) { return Open( keyname, regParent->hKey, access ); };
  27. DWORD Open( TCHAR const * keyname, HKEY hParent = (HKEY)HKEY_LOCAL_MACHINE, DWORD access = KEY_ALL_ACCESS );
  28. DWORD OpenRead( TCHAR const * keyname, TRegKey const * regParent ) { return Open( keyname, regParent->hKey, KEY_READ ); };
  29. DWORD OpenRead( TCHAR const * keyname, HKEY hParent = (HKEY)HKEY_LOCAL_MACHINE ) { return Open( keyname, hParent, KEY_READ ); };
  30. DWORD Create( TCHAR const * keyname, TRegKey const * regParent, DWORD * pDisp = NULL, DWORD access = KEY_ALL_ACCESS ) { return Create( keyname, regParent->hKey, pDisp, access ); };
  31. DWORD Create( TCHAR const * keyname, HKEY hParent = (HKEY)HKEY_LOCAL_MACHINE, DWORD * pDisp = NULL, DWORD access = KEY_ALL_ACCESS );
  32. DWORD CreateBR( TCHAR const * keyname, TRegKey const * regParent, DWORD * pDisp = NULL, DWORD access = KEY_ALL_ACCESS ) { return CreateBR( keyname, regParent->hKey, pDisp, access ); };
  33. DWORD CreateBR( TCHAR const * keyname, HKEY hParent = (HKEY)HKEY_LOCAL_MACHINE, DWORD * pDisp = NULL, DWORD access = KEY_ALL_ACCESS );
  34. HKEY KeyGet() { return hKey; }
  35. void Close();
  36. DWORD SubKeyDel( TCHAR const * keyname ) const { return RegDeleteKey( hKey, keyname ); };
  37. DWORD SubKeyRecursiveDel(TCHAR const* keyname) const;
  38. DWORD SubKeyEnum( DWORD index, TCHAR * keyname, DWORD keylen ) const;
  39. // Note that "namelen" must be "sizeof name", not "DIM(name)"
  40. // Same for "valuelen"
  41. DWORD ValueEnum( DWORD index, TCHAR * name, DWORD namelen, void * value, DWORD * valuelen, DWORD * valuetype ) const;
  42. DWORD ValueGet( TCHAR const * name, void * value, DWORD * lenvalue, DWORD * typevalue ) const;
  43. DWORD ValueGetDWORD( TCHAR const * name, DWORD * value ) const;
  44. DWORD ValueGetStr( TCHAR const * name, TCHAR * value, DWORD maxlen ) const;
  45. DWORD ValueSet( TCHAR const * name, void const * value, DWORD lenvalue, DWORD typevalue ) const;
  46. DWORD ValueSetDWORD( TCHAR const * name, DWORD value) const { return ValueSet(name, &value, sizeof value, REG_DWORD); }
  47. DWORD ValueSetStr( TCHAR const * name, TCHAR const * value, DWORD type = REG_SZ ) const;
  48. DWORD ValueDel( TCHAR const * name = NULL ) const;
  49. DWORD HiveCopy( TRegKey const * source );
  50. DWORD HiveDel();
  51. DWORD HiveReplicate( TRegKey const * source );
  52. };
  53. #endif // MCSINC_TReg.hpp
  54. // TReg.hpp - end of file