[Interest] QSettings possible bug on Windows

Alex Malyushytskyy alexmalvtk at gmail.com
Tue Oct 1 03:24:19 CEST 2013


I found a problem with QSettings when trying to read from registry.
I am using  Qt 4.7.3 so I would appreciate if anybody can check with Qt 5
at least.

Problem:
QSettings fails to return specific key value (Common AppData) when read
other keys at the same level just fine.
Key exists and verified with regedit.
Test case is below:

#include <QApplication>
#include <QSettings>
#include <QDebug>

void ddd2();

int main(int argc, char *argv[])
{
// execute test and return
    QApplication a(argc, argv);

    ddd2();

    return 0;
}

void ddd2()
{
    QSettings
reg("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell
Folders",
        QSettings::NativeFormat);
    QString key;
    QString val;

    key = QString("Common AppData");
    val = QString ( reg.value(key).toString());
    qDebug() << "key: " << key << " value: " << val;

    key = QString("Common Desktop");
    val = QString ( reg.value(key).toString());
    qDebug() << "key: " << key << " value: " << val;

    key = QString("Common Documents");
    val = QString ( reg.value(key).toString());
    qDebug() << "key: " << key << " value: " << val;
}

Output:

key:  "Common AppData"  value:  ""
key:  "Common Desktop"  value:  "C:\Users\Public\Desktop"
key:  "Common Documents"  value:  "C:\Users\Public\Documents"

Expected
 * WinXP: "c:\Documents and Settings\All Users\Application Data"
 * WinV/7/8: "c:\ProgramData"


Regards,
   Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130930/c6473fe1/attachment.html>


More information about the Interest mailing list