Hi, i'm newish to this website, (i've googled a lot for answers to my questions and often came accross very useful answers to my problems on this website) and i'm also in the middle of learning C++. As i learn new things i decide to make little programs that actually do something. My problem is that i'm trying to write information to the windows registry, and even though when i run the program, it states that it opened the key i created, it does not appear in the registry. Here's the registry aspect of the program:
HKEY hKey;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\regapptest", NULL, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) {
std::cout<<"Adding new key + value";
if ( RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\regapptest", &hKey) != ERROR_SUCCESS) {
std::cout<<"New key could not be added";
}
DWORD buffersize = 1024;
char* lpData = new char[buffersize];
char* Value = "On";
if (RegSetValueEx(hKey, "Lock", NULL, REG_SZ, (BYTE *)Value, sizeof(Value)) != ERROR_SUCCESS) {
std::cout<<"Adding Value has failed";
}
RegCloseKey(hKey);
}
else {
std::cout<<"Config Found";
RegCloseKey(hKey);
}