Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read window's registry in QT

Tags:

c++

windows

qt

I want to list all application which had been installed by reading uninstall registry file from HKEY_CURRENT_USER. But look like it can't be done by using QSettings, for some security reason ( i guess ).

QSettings maya("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall

People suggest to use WinAPI to accomplish this (at least, on Window platform)

Can somebody guide me how to add and use this lib please? Thank

like image 941
illunara Avatar asked Apr 22 '15 10:04

illunara


People also ask

How do I read registry files?

There are two ways to open Registry Editor in Windows 10: In the search box on the taskbar, type regedit, then select Registry Editor (Desktop app) from the results. Right-click Start , then select Run. Type regedit in the Open: box, and then select OK.

How do I read Windows registry files?

If you want to see what a REG file contains (or even modify one yourself), all you need is a text editor like Notepad or Notepad++. Right-click any REG file and then click the “Edit” command to open the file in your default text editor.

Which tool is used to analyze the registry entries?

The protected-mode version of the Windows Registry Checker tool (Scanregw.exe) can create a backup of the system files and scan the registry for invalid entries.


1 Answers

In order to get the list of all sub items under the "Uninstall" one in the Windows registry you need to use QSettings::childGroups() function, i.e:

QSettings m("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
            QSettings::NativeFormat);
QStringList ak = m.childGroups();

This will return the list of all installed applications.

UPDATE:

After getting the list of installed applications one can read the installation details. There are two ways for doing that. For example to read the "UinstallPath" key for "Autodesk Maya 2014" application:

m.beginGroup("Autodesk Maya 2014");
QString path = m.value("UninstallPath").toString();
m.endGroup();

or simply:

QString path = m.value("Autodesk Maya 2014/UninstallPath").toString();
like image 82
vahancho Avatar answered Sep 18 '22 18:09

vahancho