Originally posted by XSquared
Yes.
X^2, I agree with every point you made completely.
So, newbie, you're saying you want to write a program that does nothing when it runs except edit an existing registry key and then exit.. Is that right? I have a program that does just that... Let me go find it...
Ok, here's a snippet:
Code:
//---------------------cut here----------------------------
// now make the change in the registry
if (*valueName != 0 && *valueData != 0) {
processedSomething = true;
const char *keyPath = *key != 0 ? key : subKey;
// if our key path has changed...
if (keyChanged) {
keyChanged = false;
// close the previously opened key...
if (hKey != NULL) {
RegCloseKey(hKey);
hKey = NULL;
}
// then open our new path
if (RegOpenKeyEx(baseKey, keyPath, 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) {
logout << "* ERROR * - Unable to open registry key: \"" << baseKeyName << "\\" << keyPath << "\"" << endl;
hKey = NULL;
}
else
logout << "SUCCESS - Opened registry key: \"" << baseKeyName << "\\" << keyPath << "\"" << endl;
}
// if we have a key open
if (hKey != NULL) {
if (RegQueryValueEx(hKey, valueName, 0, NULL, NULL, NULL) != ERROR_SUCCESS)
logout << "* ERROR * - Unable to query value: \"" << keyPath << "\\" << valueName << "\"" << endl;
else {
logout << "SUCCESS - Queried value: \"" << keyPath << "\\" << valueName << "\"" << endl;
if (RegSetValueEx(hKey, valueName, 0, REG_SZ, valueData, strlen(valueData) + 1) != ERROR_SUCCESS)
logout << "* ERROR * - Unable to set value: \"" << keyPath << "\\" << valueName << "\"=\"" << valueData << "\"" << endl;
else
logout << "SUCCESS - Set value: \"" << keyPath << "\\" << valueName << "\"=\"" << valueData << "\"" << endl;
}
}
// reset the value info
*valueName = *valueData = 0;
}
}
// close the handle to the registry key
if (hKey != NULL) {
RegCloseKey(hKey);
hKey = NULL;
}
//---------------------cut here----------------------------