Running two different programs C++

I need help, I write two programs in C++ prg1.exe and prg2.exe and now:
1. how can prg1 starts automatically prg2
2. how can prg2 send a signal or message to prg1 if i click on the button or the mouse is over the button
3. in prg2 i want show random numbers, how can prg2 send this numbers live to prg1

thank you ...
Correct me if I am wrong, but this seems like a bad idea. Someone could replace prg2 with a malicious program and your program would run it.
@nameduser,
I don't really know how to make programs communicate, but to start a process you should see http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx (though you can do that with system("prg2.exe") )
However, if the two programs are connected, then why do you need two programs? Wouldn't two threads be enough?

@Vexer,
Sure, but some could replace notepad.exe with malicious program and double-clicking an a txt file would run it. If some one has access to your computer and wants to harm you, they'll find a way somehow.
I believe he is referring to "threads", that would be a better choice in this situation anyway. Google for C++ Threads.
To get two programs to "talk" to each other within the same server same process space, explore threads like Unix pthreads and their inter-thread communication API.

To get two programs to "talk" to each other within the same server different process space, explore Unix inter-process communication which include signal, mmap etc.

To get two programs to "talk" to each other in different servers, explore sockets programming where classic examples include telnet, http, ftp etc etc.

Above assume a Linux/Unix environment.

Topic archived. No new replies allowed.