Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-52960

Windows : wrong value when reading a registry key with REG_BINARY type.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.4.2, 5.5.1, 5.6.0
    • Core: I/O
    • None
    • Microsoft Windows 7 - 64 bits

      Having a Windows registry key with a type REG_BINARY. When reading the key using QSettings, it returns a wrong value.

      A sample code is attached to this issue (main.cpp)

      • when registry value = "01af", it returns "eabc81"
      • when registry value = "00" it returns an empty value.

      In file "qsettings_win.cpp", data (ByteArray) is converted to WCharArray with a size divided by 2.

      case REG_BINARY: {
      QString s;
      if (dataSize)

      { s = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); }

      In case of REG_BINARY, only returning the ByteArray is enough :

      case REG_BINARY:

      { if (value != 0) *value = data; break; }

      Fix proposition is attached in the diff file. On Windows 7 64 Bits, it works, I don't know if this fix covers all windows platforms ?

        1. Result 01af.png
          Result 01af.png
          25 kB
        2. Result 00.png
          Result 00.png
          24 kB
        3. Registry 01af.png
          Registry 01af.png
          69 kB
        4. Registry 00.png
          Registry 00.png
          69 kB
        5. qsettings_win.diff
          0.7 kB
        6. main.cpp
          0.4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            cnn Qt Core & Network
            randomaccess Mathias Bouvant
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes