X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdynamic.cpp;h=9984f4dbeabe5c8873bdb91b2ecc6bb1382c1f1b;hb=da29af8cba49d51e53d6e68237ccbf6370b6dd1f;hp=1470dff0cae7c0df683b7d4cd0484e2d8694267f;hpb=5b9682275e384635a1fd9f7320cf4d9a604a43b4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 1470dff0c..9984f4dbe 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -22,7 +22,7 @@ #include "inspircd.h" -#include "dynamic.h" + #ifndef _WIN32 #include #else @@ -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