在QT中读取Window的注册表 [英] Read window's registry in QT

查看:667
本文介绍了在QT中读取Window的注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过从HKEY_CURRENT_USER中读取卸载注册表文件来列出已安装的所有应用程序。但是出于安全考虑,我似乎无法使用QSettings来完成此操作(我想是)。

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

人们建议使用WinAPI来完成此操作(至少在Window平台上)

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

推荐答案

要获取Windows注册表中卸载下所有子项的列表,您需要使用 QSettings :: childGroups()函数,即:

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.

更新:

获取已安装的应用程序列表后,可以阅读安装详细信息,其中有两个w是的。例如,读取 Autodesk Maya 2014应用程序的 UinstallPath键:

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();

或简单地:

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

这篇关于在QT中读取Window的注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆