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 m_hParentKey = hParentKey;
43 open(strKey, samDesired);
64 LONG lError = ::RegCreateKeyExW(
69 REG_OPTION_NON_VOLATILE,
76 if (lError != ERROR_SUCCESS)
82 m_samDesired = samDesired;
95 LONG lError = ::RegOpenKeyExW(
102 if (lError != ERROR_SUCCESS)
108 m_samDesired = samDesired;
111void Registry::close()
116 LONG lError = ::RegCloseKey(
m_hKey);
120 if (lError != ERROR_SUCCESS)
131 info.dwDataType = REG_NONE;
134 return ::RegQueryValueExW(
144bool Registry::existsValue(
const String& strName)
147 return getDataInfo(strName, info) == ERROR_SUCCESS;
150String Registry::getString(
const String& strName)
159 LONG lError = getDataInfo(strName, info);
160 if (lError != ERROR_SUCCESS)
165 if (!((info.dwDataType == REG_EXPAND_SZ || info.dwDataType == REG_SZ)))
170 if (info.dwDataSize > 0)
172 DWORD dwDataSize = info.dwDataSize;
173 CharBuffer*
buf = CharBuffer::create(dwDataSize);
174 lError = ::RegQueryValueExW(
183 if (lError != ERROR_SUCCESS)
189 buf->__dataLength = dwDataSize;
190 buf->data()[
buf->__dataLength] = L
'\0';
198int Registry::getInteger(
const String& strName)
205 LONG lError = getDataInfo(strName, info);
206 if (lError != ERROR_SUCCESS)
211 if (info.dwDataType != REG_DWORD)
217 DWORD dwDataSize =
sizeof(dwData);
219 lError = ::RegQueryValueExW(
228 if (lError != ERROR_SUCCESS)
236void Registry::setValue(
const String& strName,
const String& strValue)
242 DWORD
len = (DWORD)strValue.length();
244 LONG lError = ::RegSetValueExW(
249 (
const byte_t*)strValue.data(),
253 if (lError != ERROR_SUCCESS)
259void Registry::setValue(
const String& strName,
int nValue)
266 DWORD dwData = (DWORD)nValue;
267 LONG lError = ::RegSetValueExW(
276 if (lError != ERROR_SUCCESS)
282bool Registry::existsKey(
const String& strKeyName, HKEY hParentKey)
284 HKEY hCurrent =
NULL;
285 LONG lError = ::RegOpenKeyExW(
292 if (lError == ERROR_SUCCESS)
294 ::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)