I have two Win32 API programs written in plain C: Program A and program B. I want program B to send the string "Hello World" to program A. So B needs to do the following:
1) Detect if program A is running.
2) If it is, send "Hello World" string to A.
3) If A is not running, B should show an error message.
Can someone point me to the API functions necessary to do this? How would I establish such a communication between two programs? I think the biggest problem is that the "Hello World" string is in the address space of program B and it somehow needs to move to the address space of A. So just passing a memory pointer is not sufficient... I need a different approach. Any ideas?
Thanks
To find the other program's main window I recommend using FindWindow
or EnumWindows
. Which one you use depends on just what you know about the other process.
Once you have that the easiest way to send text data is via a WM_COPYDATA
windows message.
To show an error message, use MessageBox
.
Google for WM_COPYDATA
. Failing that, you could use a UDP message over the local IP stack or a pipe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With