Electroneum
Loading...
Searching...
No Matches
epee::reg_utils Namespace Reference

Functions

template<class T>
bool RegSetPODValue (HKEY hParentKey, const char *pSubKey, const char *pValName, const T &valToSave, bool force_create=true)
template<class T>
bool RegGetPODValue (HKEY hParentKey, const char *pSubKey, const char *pValName, T &valToSave)
bool RegSetANSIString (HKEY hParentKey, const char *pSubKey, const char *pValName, const std::string &strToSave)
bool RegGetANSIString (HKEY hParentKey, const char *pSubKey, const char *pValName, std::string &strToSave)
template<class TMemoryObject>
bool RegSetRAWValue (HKEY hKey, const char *pValName, const TMemoryObject &valToSave, DWORD valType=REG_BINARY)
bool RegSetRAWValue (HKEY hKey, const char *pValName, const std::string &valToSave, DWORD valType=REG_BINARY)
template<class TMemoryObject>
bool RegGetRAWValue (HKEY hKey, const char *pValName, TMemoryObject &valToSave, DWORD *pRegType)
bool RegGetRAWValue (HKEY hKey, const char *pValName, std::string &valToSave, DWORD *pRegType)
template<class TMemoryObject>
bool RegSetRAWValue (HKEY hParentKey, const char *pSubKey, const char *pValName, const TMemoryObject &valToSave, DWORD valType=REG_BINARY)
bool RegSetRAWValue (HKEY hParentKey, const char *pSubKey, const char *pValName, const std::string &valToSave, DWORD valType=REG_BINARY)
template<class TMemoryObject>
bool RegGetRAWValue (HKEY hParentKey, const char *pSubKey, const char *pValName, TMemoryObject &valToSave, DWORD *pRegType)
bool RegGetRAWValue (HKEY hParentKey, const char *pSubKey, const char *pValName, std::string &valToSave, DWORD *pRegType)
bool RegRemoveValue (HKEY hParentKey, const char *pValName)
bool RegRemoveKey (HKEY hParentKey, const char *pKeyName)

Function Documentation

◆ RegGetANSIString()

bool epee::reg_utils::RegGetANSIString ( HKEY hParentKey,
const char * pSubKey,
const char * pValName,
std::string & strToSave )
inline

Definition at line 96 of file reg_utils.h.

97 {
98 HKEY hRegKey = 0;
99 LONG res = 0;
100
101
102 if((res = ::RegOpenKeyExA(hParentKey, pSubKey, 0, KEY_READ, &hRegKey)) == ERROR_SUCCESS )
103 {
104 DWORD dwType, lSize = 0;
105 res = ::RegQueryValueExA(hRegKey, pValName, 0, &dwType, NULL, &lSize);
106 if(ERROR_SUCCESS!=res)
107 {
108
109 ::RegCloseKey(hRegKey);
110 return false;
111 }
112 char* pTmpStr = new char[lSize+2];
113 memset(pTmpStr, 0, lSize+2);
114 res = ::RegQueryValueExA(hRegKey, pValName, 0, &dwType, (LPBYTE)pTmpStr, &lSize);
115 pTmpStr[lSize+1] = 0; //be happy ;)
116 strToSave = pTmpStr;
117 delete [] pTmpStr;
118 ::RegCloseKey(hRegKey);
119 }
120 return ERROR_SUCCESS==res ? true:false;
121 }
const char * res

◆ RegGetPODValue()

template<class T>
bool epee::reg_utils::RegGetPODValue ( HKEY hParentKey,
const char * pSubKey,
const char * pValName,
T & valToSave )

Definition at line 56 of file reg_utils.h.

57 {
58 HKEY hRegKey = 0;
59 LONG res = 0;
60
61
62 if(::RegOpenKeyExA(hParentKey, pSubKey, 0, KEY_READ, &hRegKey) == ERROR_SUCCESS )
63 {
64 DWORD dwType, lSize = 0;
65 res = ::RegQueryValueExA(hRegKey, pValName, 0, &dwType, NULL, &lSize);
66 if(ERROR_SUCCESS!=res || (sizeof(valToSave) < lSize) )
67 {
68 ::RegCloseKey(hRegKey);
69 return false;
70 }
71 res = ::RegQueryValueExA(hRegKey, pValName, 0, &dwType, (LPBYTE)&valToSave, &lSize);
72 }
73 return ERROR_SUCCESS==res ? true:false;
74 }

◆ RegGetRAWValue() [1/4]

bool epee::reg_utils::RegGetRAWValue ( HKEY hKey,
const char * pValName,
std::string & valToSave,
DWORD * pRegType )

Definition at line 156 of file reg_utils.h.

157 {
158 DWORD dwType, lSize = 0;
159 LONG res = ::RegQueryValueExA(hKey, pValName, 0, &dwType, NULL, &lSize);
160 if(ERROR_SUCCESS!=res || 0 >= lSize)
161 {
162 return false;
163 }
164
165 valToSave.resize(lSize);
166 res = ::RegQueryValueExA(hKey, pValName, 0, &dwType, (LPBYTE)valToSave.data(), &lSize);
167 if(pRegType) *pRegType = dwType;
168
169 return ERROR_SUCCESS==res ? true:false;
170 }

◆ RegGetRAWValue() [2/4]

template<class TMemoryObject>
bool epee::reg_utils::RegGetRAWValue ( HKEY hKey,
const char * pValName,
TMemoryObject & valToSave,
DWORD * pRegType )

Definition at line 139 of file reg_utils.h.

140 {
141 DWORD dwType, lSize = 0;
142 LONG res = ::RegQueryValueExA(hKey, pValName, 0, &dwType, NULL, &lSize);
143 if(ERROR_SUCCESS!=res || 0 >= lSize)
144 {
145 valToSave.release();
146 return false;
147 }
148 if(valToSave.get_size() < lSize)
149 valToSave.alloc_buff(lSize);
150 res = ::RegQueryValueExA(hKey, pValName, 0, &dwType, (LPBYTE)valToSave.get(0), &lSize);
151 if(pRegType) *pRegType = dwType;
152
153 return ERROR_SUCCESS==res ? true:false;
154 }
Here is the caller graph for this function:

◆ RegGetRAWValue() [3/4]

bool epee::reg_utils::RegGetRAWValue ( HKEY hParentKey,
const char * pSubKey,
const char * pValName,
std::string & valToSave,
DWORD * pRegType )
inline

Definition at line 220 of file reg_utils.h.

221 {
222 HKEY hRegKey = 0;
223 bool res = false;
224
225 if(::RegOpenKeyExA(hParentKey, pSubKey, 0, KEY_READ, &hRegKey) == ERROR_SUCCESS )
226 {
227 res = RegGetRAWValue(hRegKey, pValName, valToSave, pRegType);
228 ::RegCloseKey(hRegKey);
229 }
230 return res;
231 }
bool RegGetRAWValue(HKEY hKey, const char *pValName, TMemoryObject &valToSave, DWORD *pRegType)
Definition reg_utils.h:139
Here is the call graph for this function:

◆ RegGetRAWValue() [4/4]

template<class TMemoryObject>
bool epee::reg_utils::RegGetRAWValue ( HKEY hParentKey,
const char * pSubKey,
const char * pValName,
TMemoryObject & valToSave,
DWORD * pRegType )

Definition at line 206 of file reg_utils.h.

207 {
208 HKEY hRegKey = 0;
209 bool res = false;
210
211 if(::RegOpenKeyExA(hParentKey, pSubKey, 0, KEY_READ, &hRegKey) == ERROR_SUCCESS )
212 {
213 res = RegGetRAWValue(hRegKey, pValName, valToSave, pRegType);
214 ::RegCloseKey(hRegKey);
215 }
216 return res;
217 }
Here is the call graph for this function:

◆ RegRemoveKey()

bool epee::reg_utils::RegRemoveKey ( HKEY hParentKey,
const char * pKeyName )
inline

Definition at line 241 of file reg_utils.h.

242 {
243 //CHECK_AND_ASSERT(hParentKey&&pKeyName, false);
244 return ::RegDeleteKeyA(hParentKey, pKeyName)==ERROR_SUCCESS ? true:false;
245 }

◆ RegRemoveValue()

bool epee::reg_utils::RegRemoveValue ( HKEY hParentKey,
const char * pValName )
inline

Definition at line 234 of file reg_utils.h.

235 {
236 //CHECK_AND_ASSERT(hParentKey&&pValName, false);
237 return ::RegDeleteValueA(hParentKey, pValName)==ERROR_SUCCESS ? true:false;
238 }

◆ RegSetANSIString()

bool epee::reg_utils::RegSetANSIString ( HKEY hParentKey,
const char * pSubKey,
const char * pValName,
const std::string & strToSave )
inline

Definition at line 77 of file reg_utils.h.

78 {
79 HKEY hRegKey = 0;
80 DWORD dw = 0;
81 DWORD res_ = 0;
82 if( (res_ = ::RegCreateKeyExA(hParentKey, pSubKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hRegKey, &dw)) != ERROR_SUCCESS )
83 if( (res_= ::RegOpenKeyExA(hParentKey, pSubKey, 0, KEY_WRITE, &hRegKey)) != ERROR_SUCCESS )
84 return false;
85
86 DWORD valType = REG_SZ;
87 const char* pStr = strToSave.c_str();
88 DWORD sizeOfStr = (DWORD)strToSave.size()+1;
89 LSTATUS res = ::RegSetValueExA(hRegKey, pValName, 0, valType, (LPBYTE)pStr, sizeOfStr);
90
91 ::RegCloseKey(hRegKey);
92 return ERROR_SUCCESS==res ? true:false;
93 }

◆ RegSetPODValue()

template<class T>
bool epee::reg_utils::RegSetPODValue ( HKEY hParentKey,
const char * pSubKey,
const char * pValName,
const T & valToSave,
bool force_create = true )

Definition at line 37 of file reg_utils.h.

38 {
39 HKEY hRegKey = 0;
40 DWORD dw = 0;
41
42 if( ::RegOpenKeyExA(hParentKey, pSubKey, 0, KEY_WRITE, &hRegKey) != ERROR_SUCCESS )
43 if(force_create && (::RegCreateKeyExA(hParentKey, pSubKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hRegKey, &dw) != ERROR_SUCCESS) )
44 return false;
45
46
47 DWORD val_type = (sizeof(valToSave) == sizeof(DWORD)) ? REG_DWORD:REG_BINARY;
48
49 BOOL res = ::RegSetValueExA( hRegKey, pValName, 0, val_type, (LPBYTE)&valToSave, sizeof(valToSave)) == ERROR_SUCCESS;
50
51 ::RegCloseKey(hRegKey);
52 return ERROR_SUCCESS==res ? true:false;
53 }

◆ RegSetRAWValue() [1/4]

bool epee::reg_utils::RegSetRAWValue ( HKEY hKey,
const char * pValName,
const std::string & valToSave,
DWORD valType = REG_BINARY )

Definition at line 131 of file reg_utils.h.

132 {
133 LONG res = ::RegSetValueExA( hKey, pValName, 0, valType, (CONST BYTE*)valToSave.data(), (DWORD)valToSave.size());
134
135 return ERROR_SUCCESS==res ? true:false;
136 }

◆ RegSetRAWValue() [2/4]

template<class TMemoryObject>
bool epee::reg_utils::RegSetRAWValue ( HKEY hKey,
const char * pValName,
const TMemoryObject & valToSave,
DWORD valType = REG_BINARY )

Definition at line 124 of file reg_utils.h.

125 {
126 LONG res = ::RegSetValueExA( hKey, pValName, 0, valType, (CONST BYTE*)valToSave.get(0), (DWORD)valToSave.get_size());
127
128 return ERROR_SUCCESS==res ? true:false;
129 }
Here is the caller graph for this function:

◆ RegSetRAWValue() [3/4]

bool epee::reg_utils::RegSetRAWValue ( HKEY hParentKey,
const char * pSubKey,
const char * pValName,
const std::string & valToSave,
DWORD valType = REG_BINARY )

Definition at line 189 of file reg_utils.h.

190 {
191 HKEY hRegKey = 0;
192 DWORD dw = 0;
193 bool res = false;
194
195 if( ::RegCreateKeyExA(hParentKey, pSubKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hRegKey, &dw) != ERROR_SUCCESS )
196 if( ::RegOpenKeyExA(hParentKey, pSubKey, 0, KEY_WRITE, &hRegKey) != ERROR_SUCCESS )
197 return false;
198
199 res = RegSetRAWValue(hRegKey, pValName, valToSave, valType);
200
201 ::RegCloseKey(hRegKey);
202 return res;
203 }
bool RegSetRAWValue(HKEY hKey, const char *pValName, const TMemoryObject &valToSave, DWORD valType=REG_BINARY)
Definition reg_utils.h:124
Here is the call graph for this function:

◆ RegSetRAWValue() [4/4]

template<class TMemoryObject>
bool epee::reg_utils::RegSetRAWValue ( HKEY hParentKey,
const char * pSubKey,
const char * pValName,
const TMemoryObject & valToSave,
DWORD valType = REG_BINARY )

Definition at line 173 of file reg_utils.h.

174 {
175 HKEY hRegKey = 0;
176 DWORD dw = 0;
177 bool res = false;
178
179 if( ::RegCreateKeyExA(hParentKey, pSubKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hRegKey, &dw) != ERROR_SUCCESS )
180 if( ::RegOpenKeyExA(hParentKey, pSubKey, 0, KEY_WRITE, &hRegKey) != ERROR_SUCCESS )
181 return false;
182
183 res = RegSetRAWValue(hRegKey, pValName, valToSave, valType);
184
185 ::RegCloseKey(hRegKey);
186 return res;
187 }
Here is the call graph for this function: