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. Write key to windows registry not working
Forum Updated to NodeBB v4.3 + New Features

Write key to windows registry not working

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.7k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    mjzarrin
    wrote on 24 Nov 2015, 12:27 last edited by SGaist
    #1

    Hello dear friends
    I am admin user on windows and I need to add my software to Windows context menu.
    I can read registry key but setvalue() function doesn't work.
    this is my code:
    @
    QSettings first(address, QSettings::NativeFormat);
    QString path = first.value("hello").toString();
    qDebug() << "path: " <<path;
    first.setValue("hello", "goodbye");
    QString path2 = first.value("hello").toString();
    qDebug() << "path: " <<path2;
    @
    and this is the result:
    @
    path: "hello"
    path: "hello"
    @

    thank you all.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hskoglund
      wrote on 24 Nov 2015, 15:09 last edited by
      #2

      Hi, if you have a registry address set to something like:
      QSettings first("HKEY_CURRENT_USER\\Software\\MyCompany\\TestVariable", QSettings::NativeFormat);
      your code should work fine, but maybe you do not have write access to the place in the registry you want, what's in your variable address?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mjzarrin
        wrote on 24 Nov 2015, 15:42 last edited by
        #3

        Thank you very much for your reply
        @
        QString address("HKEY_CLASSES_ROOT\*\shell\wipefiles\command");
        QSettings first(address, QSettings::NativeFormat);
        @
        address variable is correctly set and my code can read this. i upload an snapshot from my code here.
        you are right about access permission. i insert Qsettings::status line in my code and it return 1.
        here is said that i have access limitation. how the program can access to registry for write?
        thank you.

        M 1 Reply Last reply 24 Nov 2015, 18:49
        0
        • M mjzarrin
          24 Nov 2015, 15:42

          Thank you very much for your reply
          @
          QString address("HKEY_CLASSES_ROOT\*\shell\wipefiles\command");
          QSettings first(address, QSettings::NativeFormat);
          @
          address variable is correctly set and my code can read this. i upload an snapshot from my code here.
          you are right about access permission. i insert Qsettings::status line in my code and it return 1.
          here is said that i have access limitation. how the program can access to registry for write?
          thank you.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 24 Nov 2015, 18:49 last edited by
          #4

          @mjzarrin said:

          HKEY_CLASSES_ROOT*\shell

          hi
          this might be of interrest to you
          http://stackoverflow.com/questions/25563161/access-to-registry-seems-to-be-different-from-different-sources

          1 Reply Last reply
          1
          • H Offline
            H Offline
            hskoglund
            wrote on 24 Nov 2015, 21:57 last edited by
            #5

            Indeed as @mrjj suggests with the link above, the path HKEY_CLASSES_ROOT does not exist anymore (it was present in Windows 95 but vanished in Windows 2000 and later). To be compatible, Microsoft still allows it, but reroutes it to either HKEY_LOCAL_MACHINE\Software\Classes or HKEY_CURRENT_USER\Software\Classes.

            So perhaps more successful if you try to read/write instead to HKEY_CURRENT_USER\Software\Classes\*\shell\wipefiles\command

            1 Reply Last reply
            1
            • M Offline
              M Offline
              mjzarrin
              wrote on 26 Nov 2015, 08:16 last edited by
              #6

              @mrjj @hskoglund
              thank you very much. i do what you said. i found i cant insert any key value in HKEY_CLASSES_ROOT with qt 5.5 inside Windows 8. so i instead insert my keys and values in HKEY_CURRENT_USER and it worked for bellow addresses.
              for files :"HKEY_CURRENT_USER\Software\Classes\*\shell"
              and for directories : "HKEY_CURRENT_USER\Software\Classes\directory\shell"
              thank you very much for help.

              1 Reply Last reply
              1

              1/6

              24 Nov 2015, 12:27

              • Login

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