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