Reputation: 167
Can multiple processes communicate through Message Queues or is it only for multiple thread communication ? I want to let two different processes communicate. I don t want to use shared memory because of some reasons. I want to use message queues instead. Is is doable ?
Upvotes: 0
Views: 2131
Reputation: 244772
Yes, this is possible. Call the PostMessage
function to add a message to the queue for a window, or PostThreadMessage
to add a message to the queue for a thread. (Obviously, the thread must be running a message loop.)
The WM_COPYDATA
message is explicitly designed for this purpose. It does the marshaling for you. Of course, it is a pretty basic form of marshaling: all it knows how to do is marshal a blob of bytes. It's your responsibility to interpret that blob of bytes into something useful.
There is a complete example of copying data between processes here on MSDN.
It is also worth pointing out that you don't even need WM_COPYDATA
if the amount of information that you want to pass is so small that it will fit inside of wParam
or lParam
.
Upvotes: 1
Reputation: 13690
The Message Queing is a construct for inter process communication (IPC).
You can build a data construct in the memory of one process that even can implement a queue. This can be use for quick processing e.g. for Windows messages. This must be differentiated from MSMQ.
Upvotes: 0