From 9f2f6362ee10b858f4e581851f8ecacf3e17cc75 Mon Sep 17 00:00:00 2001 From: xx Date: Tue, 11 Jun 2024 15:01:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=8A=A0=E8=BD=BD=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=A4=B1=E8=B4=A5=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/modulemanager.cpp | 20 +++++++++++++++++++- src/module/buffer.cpp | 1 - src/module/buffer.h | 16 ---------------- 3 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 src/module/buffer.cpp delete mode 100644 src/module/buffer.h diff --git a/src/core/modulemanager.cpp b/src/core/modulemanager.cpp index 36e7c38..c3fcd1e 100644 --- a/src/core/modulemanager.cpp +++ b/src/core/modulemanager.cpp @@ -33,6 +33,24 @@ fastweb::module_manager::~module_manager() } void fastweb::module_manager::start() { + auto get_last_error_desc = []()->std::string { + DWORD dwError = GetLastError(); + // 获取错误描述 + char* lpMsgBuf = nullptr; + FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dwError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL + ); + // 输出错误描述 + return std::string(lpMsgBuf); + }; close(); auto ms = modules(); for (size_t i = 0; i < ms.size(); i++) @@ -44,7 +62,7 @@ void fastweb::module_manager::start() mi.dll = LoadLibrary(mod_filepath.c_str()); if (mi.dll == nullptr) { - LOG_ERROR("module loading failed, filename: " + mod_filepath); + LOG_ERROR("module loading failed, filename: " + mod_filepath+","+ codec::to_utf8(get_last_error_desc())); continue; } mi.func = (fastweb_module_regist)GetProcAddress((HMODULE)mi.dll, "fastweb_module_regist"); diff --git a/src/module/buffer.cpp b/src/module/buffer.cpp deleted file mode 100644 index 5f28270..0000000 --- a/src/module/buffer.cpp +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/module/buffer.h b/src/module/buffer.h deleted file mode 100644 index 94af6d5..0000000 --- a/src/module/buffer.h +++ /dev/null @@ -1,16 +0,0 @@ -//#pragma once -//#include "sol/sol.hpp" -//#include "base/buffer.h" -//namespace module -//{ -// class buffer -// { -// public: -// buffer(); -// ~buffer(); -// -// void apd_str(const std::string& value); -// void apd_str(const char*); -// }; -//} -//