C++ How to make two programs communicate?

若如初见. 提交于 2019-12-03 13:35:06

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

Honestly, I'd most likely take the network-based approach. It decouples the standalone software and the plugin and as such, you could easily hook your plugin into any number of other utility programs or scripts as long as the communication protocol matches.

So, I'd probably develop the plugin to act as a server, receiving commands and responding with statuses (hey, you could even follow the HTTP standard if you really wanted to ;)).

And if you ever wanted to do cross-machine communication, it comes for free :)

Of course, depending on the software and the usage, I'd encrypt the communication.

If you're using Qt, I believe it has the notion of Plugin: How to Create Qt Plugins

Otherwise, COM works fine. With C++ , I would use the ATL library, but there is also COM support in Qt.

If you want to go more low level, I would use sockets or named pipes (since you're working with Windows)

Gui13

I'd go for sockets to establish a communication between your remote control application and the server app.

You'll find lots and lots of information by searching these keywords here on SO: IPC, RPC, sockets.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!