C ++如何使两个程序通信? [英] C++ How to make two programs communicate?

查看:264
本文介绍了C ++如何使两个程序通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:使两个程序(都在同一台计算机上运行)进行通信和交互的最佳方法是什么? (Windows,C ++)

理论情况:


  1. 在Windows PC上,我有一个第三方软件,您可以使用它来执行操作(例如打开/编辑/保存文件...这并不重要)。此第三方软件具有可用的 C ++ SDK ,因此您可以为其开发插件。

  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.

I使用GUI开发单独的独立 Windows C ++程序(很可能使用Qt)。该程序可以在与第三方软件相同的Windows计算机上运行。该程序将充当遥控器或发件人。

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.

使用第三者软件的SDK,我开发了一个很小的 第三方软件的插件。该程序充当接收器,因此我的Qt GUI可以发送该插件将接收的命令,从而相应地远程控制第三方软件

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.

因此,对于一个基本示例,我可以在独立GUI上按下一个按钮,该按钮将与插件通信,然后在第三方软件中打开指定文件。

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?

我对C ++相对较新,对Qt较新,所以请详细说明。请不要只说使用共享内存或类似的原因,因为我不会确切知道您在说什么。

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.

该程序将无法运行

我在考虑的一些问题:


  1. 如果用户同时打开多个第三方软件副本,该怎么办。我的独立软件如何知道要与哪个软件通信?

  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?

如果我已经运行了独立软件并打开了第三方软件,该插件会以某种方式具有要注册或找到与之通信的独立软件?

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?

如果我已经运行了第三方软件,然后打开独立软件,则必须进行扫描以便查看该插件是否正在运行或如何找到它?

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?

任何帮助将不胜感激。我已经在SO主题上进行了搜索,但是没有看到很多专门针对C ++的问题,而且大多数问题没有很多答案,或者说得不太清楚,或者没有专门针对与插件的软件通信。

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.

推荐答案

有很多解决方案,各有利弊。您将需要对每个阅读一些以找出最适合您的方法。没有解决方案对每个人都是最好的

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

这是一个很好的起点 http://msdn.microsoft.com/zh-CN/library/aa365574(v = vs.85).aspx

这篇关于C ++如何使两个程序通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆