From 5c756cebce6c06e9e183b6c6d1ee8debdb8b90af Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 12 Apr 2014 23:00:01 +0200 Subject: Change FormatMessage() usage in DLLManager::RetrieveLastError() to match SocketEngine::LastError() See 4451fd13a1accec8d7c2b1bb7fdafd6e50a2566b --- src/dynamic.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit v1.2.3