44 #ifndef QT_NO_SETTINGS 73 return rKey.
left(idx + 1);
84 res = rKey.
mid(idx + 1);
96 for (
int i = 0; i <
l; ++i) {
134 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, 0, 0);
149 HKEY resultHandle = 0;
150 LONG res = RegOpenKeyEx(parentHandle, reinterpret_cast<const wchar_t *>(rSubKey.
utf16()),
151 0, perms, &resultHandle);
153 if (res == ERROR_SUCCESS)
163 HKEY resultHandle =
openKey(parentHandle, perms, rSubKey);
164 if (resultHandle != 0)
168 LONG res = RegCreateKeyEx(parentHandle, reinterpret_cast<const wchar_t *>(rSubKey.
utf16()), 0, 0,
169 REG_OPTION_NON_VOLATILE, perms, 0, &resultHandle, 0);
171 if (res == ERROR_SUCCESS)
185 if (resultHandle != 0) {
193 if (resultHandle != 0) {
207 DWORD maxSubgroupSize;
210 LONG res = RegQueryInfoKey(parentHandle, 0, 0, 0, &numSubgroups, &maxSubgroupSize, 0,
211 &numKeys, &maxKeySize, 0, 0, 0);
213 if (res != ERROR_SUCCESS) {
236 for (
int i = 0; i < n; ++i) {
238 DWORD
l = buff.
size() /
sizeof(wchar_t);
240 res = RegEnumValue(parentHandle, i, reinterpret_cast<wchar_t *>(buff.
data()), &l, 0, 0, 0, 0);
242 res = RegEnumKeyEx(parentHandle, i, reinterpret_cast<wchar_t *>(buff.
data()), &l, 0, 0, 0, 0);
244 if (res == ERROR_SUCCESS)
247 if (res != ERROR_SUCCESS) {
260 HKEY handle =
openKey(parentHandle, KEY_READ, rSubKey);
268 for (
int i = 0; i < childKeys.
size(); ++i) {
272 s += childKeys.
at(i);
276 for (
int i = 0; i < childGroups.
size(); ++i) {
280 s += childGroups.
at(i);
281 allKeys(parentHandle, s, result);
289 for (
int i = 0; i < childGroups.
size(); ++i) {
294 if (childGroupHandle == 0)
297 RegCloseKey(childGroupHandle);
300 LONG res = RegDeleteKey(parentHandle, reinterpret_cast<const wchar_t *>(group.
utf16()));
301 if (res != ERROR_SUCCESS) {
302 qWarning(
"QSettings: RegDeleteKey failed on subkey \"%s\": %s",
386 void remove(
const QString &uKey);
393 bool isWritable()
const;
394 HKEY writeHandle()
const;
415 if (!application.isEmpty())
421 if (!application.isEmpty())
437 rPath = rPath.
mid(1);
465 HKEY handle =
openKey(parentHandle, KEY_READ, rSubkeyPath);
472 LONG res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubkeyName.
utf16()), 0, &dataType, 0, &dataSize);
473 if (res != ERROR_SUCCESS) {
480 res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubkeyName.
utf16()), 0, 0,
481 reinterpret_cast<unsigned char*>(data.
data()), &dataSize);
482 if (res != ERROR_SUCCESS) {
528 case REG_DWORD_BIG_ENDIAN:
532 memcpy((
char*)&i, data.
constData(),
sizeof(int));
548 qWarning(
"QSettings: Unknown data %d type in Windows registry", static_cast<int>(dataType));
571 #if defined(Q_OS_WINCE) 575 DWORD res = RegDeleteKey(
writeHandle(), reinterpret_cast<const wchar_t *>(emptyKey.
utf16()));
576 if (res != ERROR_SUCCESS) {
577 qWarning(
"QSettings: Failed to delete key \"%s\": %s",
600 res = RegDeleteValue(handle, reinterpret_cast<const wchar_t *>(
keyName(rKey).utf16()));
612 for (
int i = 0; i < childKeys.
size(); ++i) {
615 LONG res = RegDeleteValue(handle, reinterpret_cast<const wchar_t *>(group.
utf16()));
616 if (res != ERROR_SUCCESS) {
617 qWarning(
"QSettings: RegDeleteValue failed on subkey \"%s\": %s",
622 #if defined(Q_OS_WINCE) 626 res = RegDeleteKey(
writeHandle(), reinterpret_cast<const wchar_t *>(rKey.
utf16()));
628 if (res != ERROR_SUCCESS) {
629 qWarning(
"QSettings: RegDeleteKey failed on key \"%s\": %s",
639 for (
int i = 0; i < s.
length(); ++i) {
665 switch (value.
type()) {
680 if (type == REG_BINARY) {
689 regValueBuff.
append((
char)0);
690 regValueBuff.
append((
char)0);
719 if (type == REG_BINARY) {
729 LONG res = RegSetValueEx(handle, reinterpret_cast<const wchar_t *>(
keyName(rKey).utf16()), 0, type,
730 reinterpret_cast<const unsigned char*>(regValueBuff.
constData()),
731 regValueBuff.
size());
733 if (res == ERROR_SUCCESS) {
736 qWarning(
"QSettings: failed to set subkey \"%s\": %s",
750 if (handle != 0 &&
readKey(handle, rKey, value))
767 if (parent_handle == 0)
769 HKEY handle =
openKey(parent_handle, KEY_READ, rKey);
785 return result.
keys();
788 return result.
keys();
847 #endif // QT_NO_SETTINGS The QVariant class acts like a union for the most common Qt data types.
QMap< QString, QString > NameSet
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result)
void setStatus(QSettings::Status status) const
RegistryKey(HKEY parent_handle=0, const QString &key=QString(), bool read_only=true)
static QString unescapedKey(QString rKey)
static QString keyName(const QString &rKey)
#define QT_END_NAMESPACE
This macro expands to.
static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildSpec spec)
char * data()
Returns a pointer to the data stored in the byte array.
static HKEY createOrOpenKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey)
const QChar at(int i) const
Returns the character at the given index position in the string.
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
#define it(className, varName)
QByteArray & append(char c)
Appends the character ch to this byte array.
static const REGSAM registryPermissions
The QSettings class provides persistent platform-independent application settings.
QStringList children(const QString &uKey, ChildSpec spec) const
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
Format
This enum type specifies the storage format used by QSettings.
bool deleteWriteHandleOnExit
static void clear(QVariant::Private *d)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QWinSettingsPrivate(QSettings::Scope scope, const QString &organization, const QString &application)
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
static QString keyPath(const QString &rKey)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
static QSettingsPrivate * create(QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application)
static QStringList variantListToStringList(const QVariantList &l)
static void deleteChildGroups(HKEY parentHandle)
The QChar class provides a 16-bit Unicode character.
QChar * data()
Returns a pointer to the data stored in the QString.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
friend class const_iterator
static QString errorCodeToString(DWORD errorCode)
void append(const T &t)
Inserts value at the end of the list.
static bool stringContainsNullChar(const QString &s)
#define QT_BEGIN_NAMESPACE
This macro expands to.
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
void truncate(int pos)
Truncates the string at the given position index.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
void append(const T &t)
Inserts value at the end of the vector.
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QList< Key > keys() const
Returns a list containing all the keys in the map in ascending order.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
static QString variantToString(const QVariant &v)
static void mergeKeySets(NameSet *dest, const NameSet &src)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
const T & at(int i) const
Returns the item at index position i in the vector.
static QVariant stringListToVariantList(const QStringList &l)
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
void set(const QString &uKey, const QVariant &value)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Type type() const
Returns the storage type of the value stored in the variant.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
bool readKey(HKEY parentHandle, const QString &rSubKey, QVariant *value) const
int size() const
Returns the number of items in the list.
static HKEY openKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey)
int size() const
Returns the number of bytes in this byte array.
HKEY parentHandle() const
Q_CORE_EXPORT QTextStream & flush(QTextStream &s)
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
static QVariant stringToVariant(const QString &s)
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
QVector< RegistryKey > RegistryKeyList
bool get(const QString &uKey, QVariant *value) const
static QString fileName(const QString &fileUrl)
int size() const
Returns the number of items in the vector.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
static QString escapedKey(QString uKey)
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
friend class const_iterator
void remove(const QString &uKey)