1 // Windows/Registry.h 2 3 #ifndef __WINDOWS_REGISTRY_H 4 #define __WINDOWS_REGISTRY_H 5 6 #include "Common/Buffer.h" 7 #include "Common/MyString.h" 8 #include "Common/Types.h" 9 10 namespace NWindows { 11 namespace NRegistry { 12 13 LONG SetValue(HKEY parentKey, LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value); 14 15 class CKey 16 { 17 HKEY _object; 18 public: CKey()19 CKey(): _object(NULL) {} ~CKey()20 ~CKey() { Close(); } 21 HKEY()22 operator HKEY() const { return _object; } Attach(HKEY key)23 void Attach(HKEY key) { _object = key; } Detach()24 HKEY Detach() 25 { 26 HKEY key = _object; 27 _object = NULL; 28 return key; 29 } 30 31 LONG Create(HKEY parentKey, LPCTSTR keyName, 32 LPTSTR keyClass = REG_NONE, DWORD options = REG_OPTION_NON_VOLATILE, 33 REGSAM accessMask = KEY_ALL_ACCESS, 34 LPSECURITY_ATTRIBUTES securityAttributes = NULL, 35 LPDWORD disposition = NULL); 36 LONG Open(HKEY parentKey, LPCTSTR keyName, REGSAM accessMask = KEY_ALL_ACCESS); 37 38 LONG Close(); 39 40 LONG DeleteSubKey(LPCTSTR subKeyName); 41 LONG RecurseDeleteKey(LPCTSTR subKeyName); 42 43 LONG DeleteValue(LPCTSTR name); 44 #ifndef _UNICODE 45 LONG DeleteValue(LPCWSTR name); 46 #endif 47 48 LONG SetValue(LPCTSTR valueName, UInt32 value); 49 LONG SetValue(LPCTSTR valueName, bool value); 50 LONG SetValue(LPCTSTR valueName, LPCTSTR value); 51 // LONG SetValue(LPCTSTR valueName, const CSysString &value); 52 #ifndef _UNICODE 53 LONG SetValue(LPCWSTR name, LPCWSTR value); 54 // LONG SetValue(LPCWSTR name, const UString &value); 55 #endif 56 57 LONG SetValue(LPCTSTR name, const void *value, UInt32 size); 58 59 LONG SetValue_Strings(LPCTSTR valueName, const UStringVector &strings); 60 LONG GetValue_Strings(LPCTSTR valueName, UStringVector &strings); 61 62 LONG SetKeyValue(LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value); 63 64 LONG QueryValue(LPCTSTR name, UInt32 &value); 65 LONG QueryValue(LPCTSTR name, bool &value); 66 LONG QueryValue(LPCTSTR name, LPTSTR value, UInt32 &dataSize); 67 LONG QueryValue(LPCTSTR name, CSysString &value); 68 69 LONG GetValue_IfOk(LPCTSTR name, UInt32 &value); 70 LONG GetValue_IfOk(LPCTSTR name, bool &value); 71 72 #ifndef _UNICODE 73 LONG QueryValue(LPCWSTR name, LPWSTR value, UInt32 &dataSize); 74 LONG QueryValue(LPCWSTR name, UString &value); 75 #endif 76 77 LONG QueryValue(LPCTSTR name, void *value, UInt32 &dataSize); 78 LONG QueryValue(LPCTSTR name, CByteBuffer &value, UInt32 &dataSize); 79 80 LONG EnumKeys(CSysStringVector &keyNames); 81 }; 82 83 }} 84 85 #endif 86