简体   繁体   中英

Send windows message to a console application

I have a DLL that send message to the UI application, most of the messages that the DLL send contains text in them, the GUI application get the message and act according to the message.

I need to create a console application that works with the same DLL, Is there any option to get the messages to the console application, as in console application I do not have a windows message procedure.

In the GUI application I load the DLL and use one of its function to set my current HWND to the DLL, once I do this all the messages are send to my GUI.

I thought about adding a Boolean value to the DLL to know if the DLL was call from the GUI interface or from the command line console application, but that involve a lot of changes in the DLL code.

How can I get or redirect the messages to the console application (command line interface)?

The DLL, GUI and console application are coded in C/C++ using the win32 API.

Thanks in advance

You can create a window in a console application, just like in a standard Windows application. If you create a message only window (set the parent of the window to HWND_MESSAGE when calling CreateWindow() ), then it won't be visible, but will still be able to receive Windows messages. You will need to have the standard Windows message loop running somewhere in your console application in order for the messages to be dispatched to your window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM