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. [Solved] How to convert REG_SZ to String
QtWS25 Last Chance

[Solved] How to convert REG_SZ to String

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 5.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.
  • Z Offline
    Z Offline
    zolidznake
    wrote on last edited by
    #1

    Hi,

    I am trying to get informations from Windows Registry ...for example the windows install date

    but every time i get 0

    QSettings settings("HKEY_LOCAL_MACHINE\SOFTWARE\Windows NT\CurrentVersion",
    QSettings::NativeFormat);

    QString sReturnedValue = settings.value("(InstallDate)", "0").toString();
    
    std::cout << sReturnedValue.toStdString() << std::endl;
    

    Any help would be appreciated

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hpollak
      wrote on last edited by
      #2

      check if the key
      "HKEY_LOCAL_MACHINE\SOFTWARE\Windows NT\CurrentVersion\(InstallDate)" realy exists, your default value ( if not exists ) is 0

      on Windows 7 the key Path is:

      "HKEY_LOCAL_MACHINE\SOFTWARE\Micrososft\Windows NT\CurrentVersion\"

      so i think you foregot Microsoft!

      and the value is stored in:

      "InstallDate"

      But see allso:
      "section and kdey syntax":http://qt-project.org/doc/qt-5.0/qsettings.html#section-and-key-syntax

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zolidznake
        wrote on last edited by
        #3

        it returns 0 but when i am looking in windows registry i have a field InstallDate with value 503de12a

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hpollak
          wrote on last edited by
          #4

          I have also InstallDate with the value 0x50...

          but under:

          "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
          (hope mark as bold working!)

          and not under

          “HKEY_LOCAL_MACHINE\SOFTWARE\Windows NT\CurrentVersion”

          so there is no key in your path and 0 is the correct return value!!!

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hpollak
            wrote on last edited by
            #5

            Try this code it is working on my computer:

            @ QSettings settings("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", QSettings::NativeFormat);

            QString sReturnedValue = settings.value("InstallDate").toString();
            std::cout << sReturnedValue.toStdString() << std::endl;@
            
            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zolidznake
              wrote on last edited by
              #6

              if i am using WMI i can get the install date ...but from here.... i can't.

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hpollak
                wrote on last edited by
                #7

                have you tried the code snippset?

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  zolidznake
                  wrote on last edited by
                  #8

                  yes...it works...thank you for your help...

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hpollak
                    wrote on last edited by
                    #9

                    please add [solved] to the topic of this thread.

                    1 Reply Last reply
                    0

                    • Login

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