3 ms·
It's not too hard. Just write a simple wrapper around FormatMessage: DWORD errorCode = GetLastError(); DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORM
by aninteger 7y ago
It's not too hard. Just write a simple wrapper around FormatMessage:
DWORD errorCode = GetLastError();
DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
LPTSTR lpMsgBuf = NULL;
FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
// Error message is in lpMsgBuf so make sure to free afterwards.
LocalFree(lpMsgBuf);
- ksherlock 7y agoIt's even easier since the MSVC STL std::error_code (std::system_category) already does that.