X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdynamic.cpp;h=3a6a151cb5d047db124b4caca75d1a8063c0a1bf;hb=fc4fc43ec232407b38d7ca182cb92c5cac4287aa;hp=1470dff0cae7c0df683b7d4cd0484e2d8694267f;hpb=c05ad37bfd03486475889485606ed5cffc7bf5a2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 1470dff0c..3a6a151cb 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -97,9 +97,15 @@ 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; + + std::string::size_type p; + while ((p = err.find_last_of("\r\n")) != std::string::npos) + err.erase(p, 1); } #endif