A Kruger avatar 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;
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.