I am getting error 2 in my winreg function

  c++, registry, winreg

My code:

        HKEY hKey;
        char *path = "ComputerHKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlIDConfigDBHardware Profiles001HwProfileGuid";
        LONG result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, path, 0, KEY_ALL_ACCESS, &hKey);
        QString q = QString::number(result);

        if (result == ERROR_SUCCESS) {
            QMessageBox messageBox1;
            messageBox1.critical(0,"Error", "Success");
            messageBox1.setFixedSize(500,200);
        } else {
            QMessageBox messageBox2;
            messageBox2.critical(0,"Error", q);
            messageBox2.setFixedSize(500,200);
        }

The error I am getting:

https://i.stack.imgur.com/8QyT8.png

Where the key is in my registry:

https://i.stack.imgur.com/iQ9Oh.png

I think the problem is related to the way I put the info in the variable "path", but I am not sure.

Source: Windows Questions C++

LEAVE A COMMENT