47QString qt_readRegistryKey(HKEY parentHandle,
const QString &rSubkey,
unsigned long options)
52 QString rSubkeyName = keyName(rSubkey);
53 QString rSubkeyPath = keyPath(rSubkey);
55 HKEY handle =
nullptr;
56 LONG res = RegOpenKeyEx(parentHandle, (
wchar_t*)rSubkeyPath.utf16(), 0,
57 KEY_READ | options, &handle);
59 if (res != ERROR_SUCCESS)
65 res = RegQueryValueEx(handle, (
wchar_t*)rSubkeyName.utf16(),
nullptr, &dataType,
nullptr, &dataSize);
66 if (res != ERROR_SUCCESS) {
72 QByteArray data(dataSize, 0);
73 res = RegQueryValueEx(handle, (
wchar_t*)rSubkeyName.utf16(),
nullptr,
nullptr,
74 reinterpret_cast<
unsigned char*>(data.data()), &dataSize);
75 if (res != ERROR_SUCCESS) {
83 result = QString::fromWCharArray(((
const wchar_t *)data.constData()));
91 QString s = QString::fromWCharArray((
const wchar_t *)data.constData() + i);
98 result = l.join(QLatin1String(
", "));
104 result = QString::fromWCharArray((
const wchar_t *)data.constData(), data.size() / 2);
108 case REG_DWORD_BIG_ENDIAN:
110 Q_ASSERT(data.size() ==
sizeof(
int));
112 memcpy((
char*)&i, data.constData(),
sizeof(
int));
113 result = QString::number(i);
118 qWarning(
"QSettings: unknown data %u type in windows registry", quint32(dataType));
124 Q_UNUSED(parentHandle);