Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ How to make two programs communicate?

Question: What is the best way to make two programs (both running on the same computer) communicate and interact? (Windows, C++)

Theoretical situation:

  1. On a Windows PC, I have a 3rd party software that you use to do stuff (like open/edit/save files...it's not really important). This 3rd party software has an available C++ SDK so you can develop plugins for it.

  2. I develop a separate standalone Windows C++ program (most likely using Qt) with a GUI. This program is made to run on the same Windows computer as the 3rd party software. This program would act as a remote control or sender.

  3. Using the 3rd party software's SDK, I develop a tiny plugin for the 3rd party software. This program acts as a receiver, so that my Qt GUI can send commands that this plugin would receive and thus remote control the 3rd party software accordingly.

So for a basic example, I could press a button on my standalone GUI that would communicate with the plugin that would then open a specified file in the 3rd party software.

What I'm essentially looking for is to develop standalone software that would communicate back and forth with a plugin that I would develop for the 3rd party software.

What is the best approach to this? I really have no clue where to start or what to look at. Are there common C++ libraries that make this type of thing easy?

I'm relatively new to C++ and very new to Qt, so please try to elaborate. Please don't just say "Use Shared Memory" or something like that cause I'm not gonna know exactly what you are talking about.

The program would NOT be run on a separate computer, so no network stuff is necessary here I don't think.

Some questions I was thinking about:

  1. What if user has multiple copies of 3rd party software open at the same time. How does my standalone software know which one to communicate with?

  2. If I already have my standalone software running and open the 3rd party software, does the plugin somehow have to register or find my standalone software to communicate with it?

  3. If I already have the 3rd party software running and then open my standalone software does it have to scan for the plugin to see if its running or how does it find it?

Any help would be greatly appreciated. I've done a search on the topic on SO but didn't see many questions for C++ specifically and most of them didn't have many answers or weren't very clear or didn't specifically refer to software communication with a plugin for a 3rd party program.

like image 212
Jake Wilson Avatar asked Apr 30 '11 02:04

Jake Wilson


1 Answers

there are many solutions with many pros and cons. you will have to do some reading on each to work out which is best for you. no solution is best for everyone

here is a good starting place http://msdn.microsoft.com/en-us/library/aa365574(v=vs.85).aspx

like image 122
SteelBytes Avatar answered Sep 23 '22 17:09

SteelBytes