Bugfix when storing values in the windows registry

This commit is contained in:
Micke Prag 2008-10-29 11:23:36 +00:00
parent 40f06e5787
commit a9aa3c164b

View file

@ -295,10 +295,11 @@ bool TelldusSettings::setIntSetting(int intDeviceId, const char* name, int value
std::ostringstream ssRegPath;
ssRegPath << d->strRegPathDevice << intDeviceId;
string strCompleteRegPath = ssRegPath.str();
long lnExists = RegOpenKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, KEY_QUERY_VALUE, &d->hk);
long lnExists = RegOpenKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, KEY_WRITE, &d->hk);
if (lnExists == ERROR_SUCCESS) {
DWORD dwVal = value;
if (RegSetValueEx (d->hk, name, 0L, REG_DWORD, (CONST BYTE*) &dwVal, sizeof(DWORD)) == ERROR_SUCCESS) {
lnExists = RegSetValueEx (d->hk, name, 0L, REG_DWORD, (CONST BYTE*) &dwVal, sizeof(DWORD));
if (lnExists == ERROR_SUCCESS) {
blnReturn = true;
}
}