Question

I need to list the devices in the HID Bluetooth LE (BTHLE) folder of the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ directory. By using

#define REG_PATH "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\BTHLE"    
QSettings settings(REG_PATH, QSettings::NativeFormat);
QStringList regReturn = settings.allKeys();

I can get to all folders and subfolders of the path, but I need to scan through the folders, find those devices with a given PID and VID and a given value of the registrykey FriendlyName to identify my device(s).

How can this be done?

Was it helpful?

Solution

In order to obtain content of a particular sub folder, you can do the following (I used another example, because I don't know the structure of the BTHLE directory):

[..]
// Get the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_045E&PID_00B4\5&1b6962&0&1\Class key
const QString top("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB");
const QString device("VID_045E&PID_00B4");

QSettings settings(top, QSettings::NativeFormat);
settings.beginGroup(device); // Limit keys by this device only.
QStringList regReturn = settings.allKeys();
QString vStr = regReturn[1]; // 5&1b6962&0&1/Class

QString v = settings.value(regReturn[1]).toString(); // returns "USB"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top