Make hex error codes uppercase, remove title lines in braces

This commit is contained in:
Adam Demasi 2024-09-30 16:56:52 +09:30
parent 64f566990a
commit 2ee33d9c53
No known key found for this signature in database
GPG key ID: 5D3B26B3D58C7D91

View file

@ -15,7 +15,8 @@ STDAPI_(LPWSTR) GetMessageForHresult(HRESULT hr) {
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&message, 0, NULL) == 0) {
message = (LPWSTR)LocalAlloc(LPTR, 1024 * sizeof(WCHAR));
wsprintf(message, L"Error 0x%08x", hr);
wsprintf(message, L"Error 0x%08X", hr);
return message;
}
// Truncate trailing \r\n if any
@ -24,5 +25,13 @@ STDAPI_(LPWSTR) GetMessageForHresult(HRESULT hr) {
message[len - 2] = 0;
}
// Remove title part in braces
if (len > 1 && message[0] == '{') {
LPWSTR closeBrace = wcsstr(message, L"}\r\n");
if (closeBrace) {
message = closeBrace + 3;
}
}
return message;
}