#include "settingAPI.h" #include #include #include using funcInit = int (*)(const stInitData* pData); using funcCreateWindow = int (*)(int nSkinType, QWidget* parent); using funcShowWindow = int (*)(int nSkinType, int nServiceID, bool bShowWindow); using funcGetChangedData = int (*)(QString& data); using funcSave = int (*)(const int); using funcRelease = int (*)(); funcInit g_pFuncInit = nullptr; funcCreateWindow g_pFuncCreateWindow = nullptr; funcShowWindow g_pFuncShowWindow = nullptr; funcGetChangedData g_pFuncGetChangedData = nullptr; funcSave g_pFuncSaveData = nullptr; funcRelease g_pFuncRelease = nullptr; bool g_isLoaded = false; /** * @brief 加载设置动态库 * * @return true * @return false */ bool loadSettingLibrary() { if(g_isLoaded) { return true; // 已经加载过 } QString strLibPath = QCoreApplication::applicationDirPath() + "/libACAServerSetting.dll"; QLibrary lib(strLibPath); if(!lib.load()) { qWarning() << "Failed to load library:" << strLibPath << lib.errorString(); return false; } g_pFuncInit = reinterpret_cast(lib.resolve("DoInit")); g_pFuncCreateWindow = reinterpret_cast(lib.resolve("DoCreateWindow")); g_pFuncShowWindow = reinterpret_cast(lib.resolve("DoShowWindow")); g_pFuncGetChangedData = reinterpret_cast(lib.resolve("DoGetChangedData")); g_pFuncSaveData = reinterpret_cast(lib.resolve("DoSave")); g_pFuncRelease = reinterpret_cast(lib.resolve("DoRelease")); if(!g_pFuncInit || !g_pFuncCreateWindow || !g_pFuncShowWindow || !g_pFuncGetChangedData || !g_pFuncSaveData || !g_pFuncRelease) { qWarning() << "Failed to resolve functions in library:" << strLibPath; return false; } g_isLoaded = true; qDebug() << "Library loaded successfully:" << strLibPath; return true; } int DoInit(const stInitData* pData) { if(g_pFuncInit == nullptr) { qDebug() << "Function DoInit is not resolved."; return -1; // 函数未解析 } return g_pFuncInit(pData); } int DoCreateWindow(int nSkinType, QWidget* parent) { if(g_pFuncCreateWindow == nullptr) { qDebug() << "Function DoCreateWindow is not resolved."; return -1; // 函数未解析 } return g_pFuncCreateWindow(nSkinType, parent); } int DoShowWindow(int nSkinType, int nServiceID, bool bShowWindow) { if(g_pFuncShowWindow == nullptr) { qDebug() << "Function DoShowWindow is not resolved."; return -1; // 函数未解析 } return g_pFuncShowWindow(nSkinType, nServiceID, bShowWindow); } int DoGetChangedData(QString& strData) { if(g_pFuncGetChangedData == nullptr) { qDebug() << "Function DoGetChangedData is not resolved."; return -1; // 函数未解析 } return g_pFuncGetChangedData(strData); } int DoSave(const int nServiceID) { if(g_pFuncSaveData == nullptr) { qDebug() << "Function DoSaveData is not resolved."; return -1; // 函数未解析 } return g_pFuncSaveData(nServiceID); } int DoRelease() { if(g_pFuncRelease == nullptr) { qDebug() << "Function DoRelease is not resolved."; return -1; // 函数未解析 } return g_pFuncRelease(); }