[Solved] How to convert REG_SZ to String
-
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
-
check if the key
"HKEY_LOCAL_MACHINE\SOFTWARE\Windows NT\CurrentVersion\(InstallDate)" realy exists, your default value ( if not exists ) is 0on 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 -
it returns 0 but when i am looking in windows registry i have a field InstallDate with value 503de12a
-
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!!!
-
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;@
-
if i am using WMI i can get the install date ...but from here.... i can't.
-
yes...it works...thank you for your help...