Add in verbose error message and telemetry for SetWindowsHookEx failure (#6454)

* Updated error message when SetWindowsHookEx fails to show correct error message

* Added telemetry for exception in SG, FZ and KBM

* Rename exception to error
This commit is contained in:
Arjun Balgovind
2020-09-09 14:27:40 -07:00
committed by GitHub
parent f61e9d389f
commit fb1888f01f
14 changed files with 90 additions and 45 deletions

View File

@@ -82,10 +82,10 @@ public:
s_llKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), NULL);
if (!s_llKeyboardHook)
{
MessageBoxW(NULL,
GET_RESOURCE_STRING(IDS_KEYBOARD_LISTENER_ERROR).c_str(),
GET_RESOURCE_STRING(IDS_POWERTOYS_FANCYZONES).c_str(),
MB_OK | MB_ICONERROR);
DWORD errorCode = GetLastError();
show_last_error_message(L"SetWindowsHookEx", errorCode, GET_RESOURCE_STRING(IDS_POWERTOYS_FANCYZONES).c_str());
auto errorMessage = get_last_error_message(errorCode);
Trace::FancyZones::Error(errorCode, errorMessage.has_value() ? errorMessage.value() : L"", L"enable.SetWindowsHookEx");
}
}