8#if __DCL_HAVE_ALLOC_DEBUG
9#undef __DCL_ALLOC_LEVEL
10#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
15#if __DCL_HAVE_THIS_FILE__
24Registry::Registry(HKEY hParentKey)
40 __hParentKey = hParentKey;
43 open(strKey, samDesired);
65 LONG lError = RegCreateKeyExW(
70 REG_OPTION_NON_VOLATILE,
77 if (lError != ERROR_SUCCESS) {
82 __samDesired = samDesired;
95 LONG lError = RegOpenKeyExW(
102 if (lError != ERROR_SUCCESS) {
107 __samDesired = samDesired;
110void Registry::close()
115 LONG lError = RegCloseKey(
__hKey);
117 if (lError != ERROR_SUCCESS) {
127 info.dwDataType = REG_NONE;
130 return RegQueryValueExW(
140bool Registry::existsValue(
const String& strName)
143 return getDataInfo(strName, info) == ERROR_SUCCESS;
146String Registry::getString(
const String& strName)
154 LONG lError = getDataInfo(strName, info);
155 if (lError != ERROR_SUCCESS) {
159 if (!((info.dwDataType == REG_EXPAND_SZ || info.dwDataType == REG_SZ))) {
163 if (info.dwDataSize > 0) {
164 DWORD dwDataSize = info.dwDataSize;
165 CharBuffer* buf = CharBuffer::create(dwDataSize);
166 lError = RegQueryValueExW(
175 if (lError != ERROR_SUCCESS) {
180 buf->__dataLength = dwDataSize;
181 buf->data()[buf->__dataLength] = L
'\0';
189int Registry::getInteger(
const String& strName)
196 LONG lError = getDataInfo(strName, info);
197 if (lError != ERROR_SUCCESS) {
201 if (info.dwDataType != REG_DWORD) {
206 DWORD dwDataSize =
sizeof(dwData);
207 lError = RegQueryValueExW(
216 if (lError != ERROR_SUCCESS) {
223void Registry::setValue(
const String& strName,
const String& strValue)
230 DWORD len = (DWORD)strValue.length();
231 LONG lError = RegSetValueExW(
236 (
const byte_t*)strValue.data(),
240 if (lError != ERROR_SUCCESS) {
245void Registry::setValue(
const String& strName,
int nValue)
252 DWORD dwData = (DWORD)nValue;
253 LONG lError = RegSetValueExW(
262 if (lError != ERROR_SUCCESS) {
267bool Registry::existsKey(
const String& strKeyName, HKEY hParentKey)
269 HKEY hCurrent =
NULL;
270 LONG lError = RegOpenKeyExW(
277 if (lError == ERROR_SUCCESS) {
278 ::RegCloseKey(hCurrent);
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
__DCL_BEGIN_NAMESPACE struct _REGISTRY_DATAINFO REGISTRY_DATAINFO
LONG getDataInfo(const String &strName, REGISTRY_DATAINFO &info)