diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-04-12 23:00:01 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-04-12 23:00:01 +0200 |
commit | 5c756cebce6c06e9e183b6c6d1ee8debdb8b90af (patch) | |
tree | 01d3f61ec26ddf85d935a9a7a25b422cf922132a | |
parent | c17463bcae75a9f9b7108807745ec7bb2d472514 (diff) |
Change FormatMessage() usage in DLLManager::RetrieveLastError() to match SocketEngine::LastError()
See 4451fd13a1accec8d7c2b1bb7fdafd6e50a2566b
-rw-r--r-- | src/dynamic.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/dynamic.cpp b/src/dynamic.cpp index b17f13190..3a6a151cb 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -97,8 +97,10 @@ std::string DLLManager::GetVersion() #ifdef _WIN32 void DLLManager::RetrieveLastError() { - CHAR errmsg[100]; - FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errmsg, 100, 0); + char errmsg[500]; + DWORD dwErrorCode = GetLastError(); + if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)errmsg, _countof(errmsg), NULL) == 0) + sprintf_s(errmsg, _countof(errmsg), "Error code: %u", dwErrorCode); SetLastError(ERROR_SUCCESS); err = errmsg; |