From 11dfcb95b10d87677d79a7831c4087309fde0c64 Mon Sep 17 00:00:00 2001 From: jsmorley Date: Sun, 25 Apr 2010 17:42:07 +0000 Subject: [PATCH] Registry Measure: Mattking fixed a problem where a skin reading a registry value would never update the value in the skin if the key did not exist when the key was loaded, but added while the skin was running. It also would not detect that a key it had successfully read when the skin was loaded was deleted while the skin was running. --- Library/MeasureRegistry.cpp | 82 +++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/Library/MeasureRegistry.cpp b/Library/MeasureRegistry.cpp index 3cee20fb..fbf67c9f 100644 --- a/Library/MeasureRegistry.cpp +++ b/Library/MeasureRegistry.cpp @@ -53,48 +53,58 @@ CMeasureRegistry::~CMeasureRegistry() */ bool CMeasureRegistry::Update() { - if (!CMeasure::PreUpdate()) return false; + if (!CMeasure::PreUpdate()) return false; - if(m_RegKey != NULL) - { - DWORD size = 4096; - WCHAR data[4096]; - DWORD type = 0; + if(m_RegKey != NULL) + { + DWORD size = 4096; + WCHAR data[4096]; + DWORD type = 0; - if(RegQueryValueEx(m_RegKey, - m_RegValueName.c_str(), - NULL, - (LPDWORD)&type, - (LPBYTE)&data, - (LPDWORD)&size) == ERROR_SUCCESS) - { - switch(type) - { - case REG_DWORD: - m_Value = *((LPDWORD)&data); - m_StringValue.erase(); - break; + if(RegQueryValueEx(m_RegKey, + m_RegValueName.c_str(), + NULL, + (LPDWORD)&type, + (LPBYTE)&data, + (LPDWORD)&size) == ERROR_SUCCESS) + { + switch(type) + { + case REG_DWORD: + m_Value = *((LPDWORD)&data); + m_StringValue.erase(); + break; - case REG_SZ: - case REG_EXPAND_SZ: - case REG_MULTI_SZ: - m_Value = 0.0; - m_StringValue = data; - break; + case REG_SZ: + case REG_EXPAND_SZ: + case REG_MULTI_SZ: + m_Value = 0.0; + m_StringValue = data; + break; - case REG_QWORD: - m_Value = (double)((LARGE_INTEGER*)&data)->QuadPart; - m_StringValue.erase(); - break; + case REG_QWORD: + m_Value = (double)((LARGE_INTEGER*)&data)->QuadPart; + m_StringValue.erase(); + break; - default: // Other types are not supported - m_Value = 0.0; - m_StringValue.erase(); - } - } - } + default: // Other types are not supported + m_Value = 0.0; + m_StringValue.erase(); + } + } + else + { + m_Value = 0.0; + m_StringValue.erase(); + RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey); + } + } + else + { + RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey); + } - return PostUpdate(); + return PostUpdate(); } /*