My code:
HKEY hKey;
char *path = "SYSTEM\\CurrentControlSet\\Control\\IDConfigDB\\Hardware Profiles\\0001";
LONG result1 = RegOpenKeyExA(HKEY_LOCAL_MACHINE, path, 0, KEY_ALL_ACCESS, &hKey);
QString q = QString::number(result1);
if (result1 == ERROR_SUCCESS) {
LPDWORD b {};
char *buffer[250];
LONG result12 = RegGetValueA(hKey, path, "HwProfileGuid", RRF_RT_REG_SZ, NULL, &buffer, b);
if (result12 == ERROR_SUCCESS) {
QMessageBox messageBox1;
messageBox1.critical(0,"Error", "Sucesso");
messageBox1.setFixedSize(500,200);
} else {
QString q = QString::number(result12);
QMessageBox messageBox2;
messageBox2.critical(0,"Error", q);
messageBox2.setFixedSize(500,200);
}
} else {
QMessageBox messageBox2;
messageBox2.critical(0,"Error", q);
messageBox2.setFixedSize(500,200);
}
I am a beginner and I am unsure of what parameter is the invalid one.
RegGetValueA function (winreg.h) - Win32 apps | Microsoft Docs says:
Your
pvData
is&buffer
, which won't beNULL
, but yourpcbData
isb
, which is initialized toNULL
. Therefore this condition is not satisfied.Also there looks like more errors:
pvData
is stored.RegOpenKeyExA
, so you shouldn't specify that forRegGetValueA
again. Otherwise, it will try to read the path under the path (SYSTEM\...\0001\SYSTEM\...\0001
).The part
should be