Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send a byte array to another process in C++

I have been checking on the site for a way to transfer data from a process to another one in C++. I found the method SendMessage() but it does not seem to be able to take a byte array.

To explain a little bit the context here, I have an application that send data to another one. We have several objects with different IDs. The app that receives creates a tab for every different objects. If the app that is receiving the data is closed, we start a new process and show the data to the user. If we send a second time, we need to check with IDs to see if we already have one of the objects, if yes replace it. Otherwise add new tabs for the new objects.

We use protocol buffers from google and they work with byte arrays for transportation and serialization, so that's why I need to find a way to send a byte array from a process to another.

I was able to get the HWND of the process but I don't know where to go from now.

like image 258
Jean-François Deschênes Avatar asked Nov 19 '12 14:11

Jean-François Deschênes


1 Answers

Interprocess communication is a plattform-specific thing. In Windows, there are many ways to do that. This MSDN article describes several methods and their pros, cons and use-cases:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx

When you control both applications, and support for 3rd party applications is no concern for you, then sending the WM_COPYDATA message through SendMessage() to the other process might be a good approach.

like image 76
Philipp Avatar answered Sep 18 '22 05:09

Philipp