1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r
8 # include "stringtool.h"
\r
12 /// registry access class
\r
15 HKEY m_root; /// registry root
\r
16 tstring m_path; /// path from registry root
\r
19 typedef std::list<tstring> tstrings;
\r
23 Registry() : m_root(NULL) { setRoot(NULL, _T("")); }
\r
25 Registry(HKEY i_root, const tstring &i_path)
\r
26 : m_root(i_root), m_path(i_path) { setRoot(i_root, i_path); }
\r
28 /// set registry root and path
\r
29 void setRoot(HKEY i_root, const tstring &i_path)
\r
33 _TCHAR exePath[GANA_MAX_PATH];
\r
34 _TCHAR exeDrive[GANA_MAX_PATH];
\r
35 _TCHAR exeDir[GANA_MAX_PATH];
\r
36 GetModuleFileName(NULL, exePath, GANA_MAX_PATH);
\r
37 _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0);
\r
40 m_path += _T("yamy.ini");
\r
44 bool remove(const tstring &i_name = _T("")) const
\r
45 { return remove(m_root, m_path, i_name); }
\r
47 /// does exist the key ?
\r
48 bool doesExist() const { return doesExist(m_root, m_path); }
\r
51 bool read(const tstring &i_name, int *o_value, int i_defaultValue = 0)
\r
53 { return read(m_root, m_path, i_name, o_value, i_defaultValue); }
\r
55 bool write(const tstring &i_name, int i_value) const
\r
56 { return write(m_root, m_path, i_name, i_value); }
\r
59 bool read(const tstring &i_name, tstring *o_value,
\r
60 const tstring &i_defaultValue = _T("")) const
\r
61 { return read(m_root, m_path, i_name, o_value, i_defaultValue); }
\r
63 bool write(const tstring &i_name, const tstring &i_value) const
\r
64 { return write(m_root, m_path, i_name, i_value); }
\r
67 /// read list of tstring
\r
68 bool read(const tstring &i_name, tstrings *o_value,
\r
69 const tstrings &i_defaultValue = tstrings()) const
\r
70 { return read(m_root, m_path, i_name, o_value, i_defaultValue); }
\r
71 /// write list of tstring
\r
72 bool write(const tstring &i_name, const tstrings &i_value) const
\r
73 { return write(m_root, m_path, i_name, i_value); }
\r
75 /// read binary data
\r
76 bool read(const tstring &i_name, BYTE *o_value, DWORD i_valueSize,
\r
77 const BYTE *i_defaultValue = NULL, DWORD i_defaultValueSize = 0)
\r
79 { return read(m_root, m_path, i_name, o_value, i_valueSize, i_defaultValue,
\r
80 i_defaultValueSize); }
\r
81 /// write binary data
\r
82 bool write(const tstring &i_name, const BYTE *i_value,
\r
83 DWORD i_valueSize) const
\r
84 { return write(m_root, m_path, i_name, i_value, i_valueSize); }
\r
89 static bool remove(HKEY i_root, const tstring &i_path,
\r
90 const tstring &i_name = _T(""));
\r
92 /// does exist the key ?
\r
93 static bool doesExist(HKEY i_root, const tstring &i_path);
\r
96 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
97 int *o_value, int i_defaultValue = 0);
\r
99 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
103 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
104 tstring *o_value, const tstring &i_defaultValue = _T(""));
\r
106 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
107 const tstring &i_value);
\r
110 /// read list of tstring
\r
111 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
112 tstrings *o_value, const tstrings &i_defaultValue = tstrings());
\r
113 /// write list of tstring
\r
114 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
115 const tstrings &i_value);
\r
117 /// read binary data
\r
118 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
119 BYTE *o_value, DWORD i_valueSize,
\r
120 const BYTE *i_defaultValue = NULL,
\r
121 DWORD i_defaultValueSize = 0);
\r
122 /// write binary data
\r
123 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
124 const BYTE *i_value, DWORD i_valueSize);
\r
127 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
128 LOGFONT *o_value, const tstring &i_defaultStringValue);
\r
130 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
131 const LOGFONT &i_value);
\r
135 #endif // !_REGISTRY_H
\r