Commits

A Kruger committed 862b636

Add debug logs when writing the registry fails.

Comments (0)

Files changed (1)

Client/psiclient/utilities.cpp

     HKEY key = 0;
     DWORD disposition = 0;
     DWORD bufferLength = sizeof(value);
+    LONG returnCode = 0;
 
     bool success = 
-        (ERROR_SUCCESS == RegCreateKeyEx(
+        (ERROR_SUCCESS == returnCode = RegCreateKeyEx(
                             HKEY_CURRENT_USER,
                             LOCAL_SETTINGS_REGISTRY_KEY,
                             0,
                             &key,
                             &disposition) &&
 
-         ERROR_SUCCESS == RegSetValueExA(
+         ERROR_SUCCESS == returnCode = RegSetValueExA(
                             key,
                             name.c_str(),
                             0,
                             bufferLength));
     RegCloseKey(key);
 
+    if (!success)
+    {
+        my_print(NOT_SENSITIVE, true, _T("%s failed for %S with code %ld"), __TFUNCTION__, name.c_str(), returnCode);
+    }
+
     return success;
 }
 
 bool WriteRegistryStringValue(const string& name, const string& value)
 {
     HKEY key = 0;
+    LONG returnCode = 0;
 
     bool success = 
-        (ERROR_SUCCESS == RegCreateKeyEx(
+        (ERROR_SUCCESS == returnCode = RegCreateKeyEx(
                             HKEY_CURRENT_USER,
                             LOCAL_SETTINGS_REGISTRY_KEY,
                             0,
                             0,
                             &key,
                             0) &&
-         ERROR_SUCCESS == RegSetValueExA(
+
+         ERROR_SUCCESS == returnCode = RegSetValueExA(
                             key,
                             name.c_str(),
                             0,
                             value.length() + 1)); // Write the null terminator
     RegCloseKey(key);
 
+    if (!success)
+    {
+        my_print(NOT_SENSITIVE, true, _T("%s failed for %S with code %ld"), __TFUNCTION__, name.c_str(), returnCode);
+    }
+
     return success;
 }