forked from elifiner/recaps
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.c
59 lines (48 loc) · 1.35 KB
/
utils.c
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
48
49
50
51
52
53
54
55
56
57
58
59
#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);
}
///////////////////////////////////////////////////////////////////////////////
// Checks whether the requested command line switch exists
BOOL DoesCmdLineSwitchExists(const WCHAR* command)
{
for(int i = 1; i < __argc; i++)
{
if(_wcsicmp(command, __wargv[i]) == 0)
return TRUE;
}
return FALSE;
}