-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.cpp
More file actions
39 lines (36 loc) · 938 Bytes
/
Copy pathmisc.cpp
File metadata and controls
39 lines (36 loc) · 938 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
33
34
35
36
37
38
39
#include "Util.hpp"
#include <iostream>
DWORD ErrorMessage(LSTATUS ErrorCode);
VOID
ErrorCheck(LSTATUS ErrorCode)
{
if(ErrorCode != ERROR_SUCCESS)
{
ErrorMessage(ErrorCode);
ExitProcess(1);
}
return;
}
DWORD
ErrorMessage(LSTATUS ErrorCode)
{
DWORD dw;
LPVOID lpBuffer = NULL;
if(ErrorCode == NULL)
dw = GetLastError();
else
dw = ErrorCode;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpBuffer, 0, NULL);
if (lpBuffer != NULL)
{
std::wcout << (LPTSTR) lpBuffer << std::endl;
LocalFree(lpBuffer);
lpBuffer = NULL;
return ERROR_SUCCESS;
}
return 0;
}