Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [Solved] How to convert REG_SZ to String

    General and Desktop
    2
    9
    4950
    Loading More Posts
    • 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
      zolidznake last edited by

      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 Reply Quote 0
      • H
        hpollak last edited by

        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 Reply Quote 0
        • Z
          zolidznake last edited by

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

          1 Reply Last reply Reply Quote 0
          • H
            hpollak last edited by

            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 Reply Quote 0
            • H
              hpollak last edited by

              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 Reply Quote 0
              • Z
                zolidznake last edited by

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

                1 Reply Last reply Reply Quote 0
                • H
                  hpollak last edited by

                  have you tried the code snippset?

                  1 Reply Last reply Reply Quote 0
                  • Z
                    zolidznake last edited by

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

                    1 Reply Last reply Reply Quote 0
                    • H
                      hpollak last edited by

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

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post