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
38 _TCHAR exePath[GANA_MAX_PATH];
\r
39 _TCHAR exeDrive[GANA_MAX_PATH];
\r
40 _TCHAR exeDir[GANA_MAX_PATH];
\r
41 GetModuleFileName(NULL, exePath, GANA_MAX_PATH);
\r
42 _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0);
\r
45 m_path += _T("yamy.ini");
\r
50 bool remove(const tstring &i_name = _T("")) const {
\r
51 return remove(m_root, m_path, i_name);
\r
54 /// does exist the key ?
\r
55 bool doesExist() const {
\r
56 return doesExist(m_root, m_path);
\r
60 bool read(const tstring &i_name, int *o_value, int i_defaultValue = 0)
\r
62 return read(m_root, m_path, i_name, o_value, i_defaultValue);
\r
65 bool write(const tstring &i_name, int i_value) const {
\r
66 return write(m_root, m_path, i_name, i_value);
\r
70 bool read(const tstring &i_name, tstring *o_value,
\r
71 const tstring &i_defaultValue = _T("")) const {
\r
72 return read(m_root, m_path, i_name, o_value, i_defaultValue);
\r
75 bool write(const tstring &i_name, const tstring &i_value) const {
\r
76 return write(m_root, m_path, i_name, i_value);
\r
80 /// read list of tstring
\r
81 bool read(const tstring &i_name, tstrings *o_value,
\r
82 const tstrings &i_defaultValue = tstrings()) const {
\r
83 return read(m_root, m_path, i_name, o_value, i_defaultValue);
\r
85 /// write list of tstring
\r
86 bool write(const tstring &i_name, const tstrings &i_value) const {
\r
87 return write(m_root, m_path, i_name, i_value);
\r
91 /// read binary data
\r
92 bool read(const tstring &i_name, BYTE *o_value, DWORD *i_valueSize,
\r
93 const BYTE *i_defaultValue = NULL, DWORD i_defaultValueSize = 0)
\r
95 return read(m_root, m_path, i_name, o_value, i_valueSize, i_defaultValue,
\r
96 i_defaultValueSize);
\r
98 /// write binary data
\r
99 bool write(const tstring &i_name, const BYTE *i_value,
\r
100 DWORD i_valueSize) const {
\r
101 return write(m_root, m_path, i_name, i_value, i_valueSize);
\r
106 static bool remove(HKEY i_root, const tstring &i_path,
\r
107 const tstring &i_name = _T(""));
\r
109 /// does exist the key ?
\r
110 static bool doesExist(HKEY i_root, const tstring &i_path);
\r
113 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
114 int *o_value, int i_defaultValue = 0);
\r
116 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
120 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
121 tstring *o_value, const tstring &i_defaultValue = _T(""));
\r
123 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
124 const tstring &i_value);
\r
127 /// read list of tstring
\r
128 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
129 tstrings *o_value, const tstrings &i_defaultValue = tstrings());
\r
130 /// write list of tstring
\r
131 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
132 const tstrings &i_value);
\r
135 /// read binary data
\r
136 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
137 BYTE *o_value, DWORD *i_valueSize,
\r
138 const BYTE *i_defaultValue = NULL,
\r
139 DWORD i_defaultValueSize = 0);
\r
140 /// write binary data
\r
141 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
142 const BYTE *i_value, DWORD i_valueSize);
\r
144 static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
145 LOGFONT *o_value, const tstring &i_defaultStringValue);
\r
147 static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
\r
148 const LOGFONT &i_value);
\r
152 #endif // !_REGISTRY_H
\r