-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.cpp
47 lines (37 loc) · 1.11 KB
/
utils.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "stdafx.h"
#define BUFSIZE 2048
///////////////////////////////////////////////////////////////////////////////
// Shows a system error message
void ShowError(const WCHAR* message)
{
WCHAR buffer[BUFSIZE];
LPVOID errMessage;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&errMessage,
0,
NULL
);
buffer[0] = '\0';
wcscat_s(buffer, BUFSIZE, message);
wcscat_s(buffer, BUFSIZE, L"\n\nError : ");
wcscat_s(buffer, BUFSIZE, (const WCHAR*)errMessage);
MessageBox(NULL, (const WCHAR*)buffer, L"Recaps Error", MB_OK | MB_ICONINFORMATION);
LocalFree(errMessage);
}
///////////////////////////////////////////////////////////////////////////////
// Prints an error message to the debugger
void PrintDebugString(const char* format, ...)
{
char buffer[2048];
va_list args;
va_start(args, format);
vsprintf_s(buffer, 2048, format, args);
strcat_s(buffer, 2048, "\n");
OutputDebugStringA(buffer);
}