dll to main program communication

给你一囗甜甜゛ 提交于 2020-01-25 02:23:45

问题


I want to trace some text from dll module to a main program window (to a log subwindow). How can I do this correctly? (through kernel primitives, via sending messages from window to window, passing callback interfaces?) The working example I've seen: Matlab and Octave. When calling mexPrintf then output printed in their main windows.


回答1:


Your main program should export a logging function and make it known to the DLL. Your DLL needs to export a function, such as InitLogging, that takes a function pointer and stores the passed value somewhere into its global data.

An alternative is to put your "main" program in another DLL and make a "stub" main that links all the DLLs together.

(On Windows, DLLs can call each other's functions, but a DLL cannot call a function in the main program. On unix, this is much simpler, as shared objects can directly call the main program's functions.)



来源:https://stackoverflow.com/questions/7221776/dll-to-main-program-communication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!