开发者

dll to main program communication

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.


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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜