输出加载模块失败原因

This commit is contained in:
xx
2024-06-11 15:01:03 +08:00
parent bd1bf7eaa0
commit 9f2f6362ee
3 changed files with 19 additions and 18 deletions

View File

@@ -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");

View File

@@ -1 +0,0 @@

View File

@@ -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*);
// };
//}
//