Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to save a file path in a single entry (Windows Registry by using QSettings?

How to save a file path in a single entry (Windows Registry by using QSettings?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsettingswindows
2 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on 8 Jun 2016, 11:34 last edited by
    #1

    I want to enable the Windows XP Compatibility Mode in my app by clicking in an action in the app. The steps are easy:

    • Acces to the Windows Registry
    • Go to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\
    • Add a new entry with the path of the exe file. Finally, set "WINXPSP3" as value.
    • The next time, the app will be launched in this mode.

    Now, im trying to implement it on Qt by using QSettings:

    • First, get the current file path of the exe file
        const QString appPath = QCoreApplication::applicationFilePath();
    
    
    • Go in QSetting to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\
     const QString regPath = QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\\");
        QSettings* reg = new QSettings(regPath, QSettings::NativeFormat);
    
    • Now Add the entry:
        reg->setValue(appPath, "WINXPSP3");
    
    

    What is the problem?
    QT didn't create an entry with this value. Qt create multiple subgroups depending of the directory tree. Example: C:\Program Files (x86)\Example\example.exe

    "C:" -> "Program Files (x86)" -> "Example" -> "example.exe" (value WINXPSP3).

    But i want:

    "C:\Program Files (x86)\Example\example.exe" (value WINXPSP3)

    Anyone, could help me?

    Sorry for my poor english.

    T 1 Reply Last reply 8 Jun 2016, 13:13
    0
    • ? A Former User
      8 Jun 2016, 11:34

      I want to enable the Windows XP Compatibility Mode in my app by clicking in an action in the app. The steps are easy:

      • Acces to the Windows Registry
      • Go to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\
      • Add a new entry with the path of the exe file. Finally, set "WINXPSP3" as value.
      • The next time, the app will be launched in this mode.

      Now, im trying to implement it on Qt by using QSettings:

      • First, get the current file path of the exe file
          const QString appPath = QCoreApplication::applicationFilePath();
      
      
      • Go in QSetting to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\
       const QString regPath = QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\\");
          QSettings* reg = new QSettings(regPath, QSettings::NativeFormat);
      
      • Now Add the entry:
          reg->setValue(appPath, "WINXPSP3");
      
      

      What is the problem?
      QT didn't create an entry with this value. Qt create multiple subgroups depending of the directory tree. Example: C:\Program Files (x86)\Example\example.exe

      "C:" -> "Program Files (x86)" -> "Example" -> "example.exe" (value WINXPSP3).

      But i want:

      "C:\Program Files (x86)\Example\example.exe" (value WINXPSP3)

      Anyone, could help me?

      Sorry for my poor english.

      T Offline
      T Offline
      the_
      wrote on 8 Jun 2016, 13:13 last edited by the_ 6 Aug 2016, 13:14
      #2

      @mojito

      As mentioned in the documentation a single "\" or "/" indicates a subkey separator. You could try to use "\\" instead of "\".

      -- No support in PM --

      1 Reply Last reply
      0

      1/2

      8 Jun 2016, 11:34

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved