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) {
\r
24 setRoot(NULL, _T(""));
\r
27 Registry(HKEY i_root, const tstring &i_path)
\r
28 : m_root(i_root), m_path(i_path) {
\r
29 setRoot(i_root, i_path);
\r
32 /// set registry root and path
\r
33 void setRoot(HKEY i_root, const tstring &i_path) {
\r
36 _TCHAR exePath[GANA_MAX_PATH];
\r
37 _TCHAR exeDrive[GANA_MAX_PATH];
\r
38 _TCHAR exeDir[GANA_MAX_PATH];
\r
39 GetModuleFileName(NULL, exePath, GANA_MAX_PATH);
\r
40 _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0);
\r
43 m_path += _T("yamy.ini");
\r
47 bool remove(const tstring &i_name = _T("")) const {
\r
48 return remove(m_root, m_path, i_name);
\r
51 /// does exist the key ?
\r
52 bool doesExist() const {
\r
53 return doesExist(m_root, m_path);
\r
57 bool read(const tstring &i_name, int *o_value, int i_defaultValue = 0)
\r
59 return read(m_root, m_path, i_name, o_value, i_defaultValue);
\r
62 bool write(const tstring &i_name, int i_value) const {
\r
63 return write(m_root, m_path, i_name, i_value);
\r
67 bool read(const tstring &i_name, tstring *o_value,
\r
68 const tstring &i_defaultValue = _T("")) const {
\r
69 return read(m_root, m_path, i_name, o_value, i_defaultValue);
\r
72 bool write(const tstring &i_name, const tstring &i_value) const {
\r
73 return write(m_root, m_path, i_name, i_value);
\r
77 /// read list of tstring
\r
78 bool read(const tstring &i_name, tstrings *o_value,
\r
79 const tstrings &i_defaultValue = tstrings()) const {
\r
80 return read(m_root, m_path, i_name, o_value, i_defaultValue);
\r
82 /// write list of tstring
\r
83 bool write(const tstring &i_name, const tstrings &i_value) const {
\r
84 return write(m_root, m_path, i_name, i_value);
\r
87 /// read binary data
\r
88 bool read(const tstring &i_name, BYTE *o_value, DWORD i_valueSize,
\r
89 const BYTE *i_defaultValue = NULL, DWORD i_defaultValueSize = 0)
\r
91 return read(m_root, m_path, i_name, o_value, i_valueSize, i_defaultValue,
\r
92 i_defaultValueSize);
\r
94 /// write binary data
\r
95 bool write(const tstring &i_name, const BYTE *i_value,
\r
96 DWORD i_valueSize) const {
\r
97 return write(m_root, m_path, i_name, i_value, i_valueSize);
\r
103 static bool remove(HKEY i_root, const tstring &i_path,
\r
104 const tstring &i_name = _T(""));
\r
106 /// does exist the key ?
\r
107 static bool doesExist(HKEY i_root, const tstring &i_path);
\r
110 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
111 int *o_value, int i_defaultValue = 0);
\r
113 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
117 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
118 tstring *o_value, const tstring &i_defaultValue = _T(""));
\r
120 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
121 const tstring &i_value);
\r
124 /// read list of tstring
\r
125 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
126 tstrings *o_value, const tstrings &i_defaultValue = tstrings());
\r
127 /// write list of tstring
\r
128 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
129 const tstrings &i_value);
\r
131 /// read binary data
\r
132 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
133 BYTE *o_value, DWORD i_valueSize,
\r
134 const BYTE *i_defaultValue = NULL,
\r
135 DWORD i_defaultValueSize = 0);
\r
136 /// write binary data
\r
137 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
138 const BYTE *i_value, DWORD i_valueSize);
\r
141 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
142 LOGFONT *o_value, const tstring &i_defaultStringValue);
\r
144 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
145 const LOGFONT &i_value);
\r
149 #endif // !_REGISTRY_H
\r