-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
#include
#include
#include
#include <Windows.h>
std::string LastError()
{
LPWSTR buffer;
FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr,
GetLastError(),
0,
(LPWSTR)&buffer,
0,
nullptr);
int required = WideCharToMultiByte(
CP_UTF8,
0,
buffer,
-1,
nullptr,
0,
nullptr,
nullptr);
std::string output;
output.resize(required);
WideCharToMultiByte(
CP_UTF8,
0,
buffer,
-1,
output.data(),
output.size(),
nullptr,
nullptr);
LocalFree(buffer);
return output;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels