How to send an array of bytes to another process in C ++

I check on the site how to transfer data from the process to another in C ++. I found the SendMessage () method, but it looks like it cannot accept a byte array.

To explain the context here a bit, I have an application that sends data to another. We have several objects with different identifiers. The application that receives creates a tab for each other object. If the application that receives 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 the identifiers to see if we have one of the objects, if so, replace it. Otherwise, add new tabs for new objects.

We use protocol buffers from Google, and they work with byte arrays for transportation and serialization, so I need to find a way to send an array of bytes from a process to another.

I managed to get the HWND of this process, but I don’t know where to start.

+4
source share
2 answers

Interprocess communication is a specific form. There are many ways to do this on Windows. 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 manage both applications and support third-party applications, you are not interested, then send the WM_COPYDATA message via SendMessage () so that another process can be a good approach.

+3
source

If you want to use SendMessage, you can use the WM_COPYDATA message to send a data block, although this is just a block of bytes, not an object.

+2
source

Source: https://habr.com/ru/post/1446958/


All Articles