-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy patherror.c
More file actions
32 lines (27 loc) · 670 Bytes
/
error.c
File metadata and controls
32 lines (27 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <Windows.h>
#include "error.h"
void reportGeneralError(WCHAR* message)
{
MessageBoxW(NULL, message, L"LightWM Error", MB_OK);
}
void reportWin32Error(WCHAR* message)
{
DWORD lastError = GetLastError();
WCHAR* messageBuffer;
reportGeneralError(message);
if (FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
lastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&messageBuffer,
0,
NULL) == 0) {
reportGeneralError(L"FormatMessageW has failed");
return;
}
MessageBoxW(NULL, messageBuffer, L"LightWM Last Win32 Error", MB_OK);
LocalFree(messageBuffer);
}