Anyone have a good tutorial on getting two programs (on the same computer for now) to talk to each other?
Printable View
Anyone have a good tutorial on getting two programs (on the same computer for now) to talk to each other?
Sockets and a loopback address.
If it is two apps you have written try
RegisterWindowMessage()
to set up your message.
Then
PostMessage() if you don't want to wait for the other app to process the msg.
or
SendMessage() if you do.
In both cases use HWND_BROADCAST for the hwnd param. This will send the msg to all top level windows. If yours has been coded to respond it will.
The WPARAM and LPARAM can be used to send other data.
GetCurrentProcessId() will help in identifing (multiple instances) which app sent the message. Try sending it as say the WPARAM. The LPARAM can could contain the type of message
>>> (on the same computer for now)
The "for now" is the important point here. If they are on the same computer, then there are a number of possibilities, you can exchange messages as novacain has suggested, you can build pipes between the tasks, you can use a mailslot, or another method of allocating shared memory. You can even use a file.
If you intend to network this one day, then most of these will not work and you should use sockets, specifically WinSock.
This is usually the first link I give in these cases.
Thanks for the replys all. I think I'll try my hand at winsocks since I do wish to network the program in the future.