【发布时间】:2020-04-17 09:52:29
【问题描述】:
代码涉及将使用情况监控 dll 集成到现有主机 dll。主机 dll 由 WX GUI 应用程序加载以进行回调。使用监控 dll 的工作原理如下。
初始化 //f1
usageexportfrequency //f2
将使用信号导出到服务器 // f3
deinit //f4
f1 集成到我的主机 dll 初始化例程中,f2 集成到主机 dll 中基于事件的函数,同样 deinit 集成到我的主机 dll deinit。
当我只集成 f1 和 f3 时,gui 不会崩溃并且工作正常。当我集成主 f2 函数以指示在我的主机 dll 中使用回调函数并运行 GUI 应用程序时,当我更改小部件值时它会立即崩溃。
但是,当我在示例程序(EXE 不是主机 dll)中使用“使用”dll 时,它就像一个魅力。
HINSTANCE hGetProcIDDLL;
typedef void (__stdcall *lgUsgIn)(bool);
typedef void (__stdcall *SetMinInt)(long);
typedef bool (__stdcall *lgUsgSnd)(const char*,const char*,const char*);
typedef void(__stdcall *waitforCom)(void);
lgUsgIn LogUsageInit;
lgUsgSnd LogUsageSend;
SetMinInt SetMinInterval;
waitforCom WaitForCompletion;
hGetProcIDDLL = LoadLibrary("D:\\HTA_NG_DevEnvironment\\Utilization\\LogUsage.dll");
LogUsageInit = (lgUsgIn)GetProcAddress(hGetProcIDDLL, "LogUsageInit");
SetMinInterval = (SetMinInt)GetProcAddress(hGetProcIDDLL, "SetMinInterval");
LogUsageSend = (lgUsgSnd)GetProcAddress(hGetProcIDDLL, "LogUsageSend");
WaitForCompletion = (waitforCom)GetProcAddress(hGetProcIDDLL, "WaitForCompletion");
LogUsageInit(1);
SetMinInterval(600);
const char tool[] = "tooln1";
const char opt[] = "remoteValidation";
const char tag[] = "none";
bool OutCome = LogUsageSend(tool,opt,tag); // **crash happens when this function is included**
WaitForCompletion();
FreeLibrary(hGetProcIDDLL);
用于将主机 Dll 加载到 WX GUI 应用程序的函数也是来自 wxDynamicLibrary 类的函数 Load()。
【问题讨论】: