Transferring data between executable files

I have two executables written in C ++ on Windows. I am generating some data in one and want to call another executable to process this data. I could write the data to a file and then read it in another executable file, but that seems pretty expensive in terms of I / O. What is the best way to do this? This seems like a pretty simple question, but google just doesn't help!

Say the data is about 100 MB and is fully generated before it needs to be sent (i.e. streaming is not required).

Answers that work when mixing 32-bit and 64-bit processes receive bonus points.

+5
source share
3 answers

, . CreateFile . Windows , - . 100 , Windows .

+4

Boost.MPI. Boost, , :

http://www.boost.org/doc/libs/1_53_0/doc/html/mpi/tutorial.html#mpi.point_to_point

// The following program uses two MPI processes to write "Hello, world!"
// to the screen (hello_world.cpp):

int main(int argc, char* argv[])
{
  mpi::environment env(argc, argv);
  mpi::communicator world;

  if (world.rank() == 0) {
    world.send(1, 0, std::string("Hello"));
    std::string msg;
    world.recv(1, 1, msg);
    std::cout << msg << "!" << std::endl;
  } else {
    std::string msg;
    world.recv(0, 0, msg);
    std::cout << msg << ", ";
    std::cout.flush();
    world.send(0, 1, std::string("world"));
  }
  return 0;
}
+3

, " " ( BACK ), _popen(). , stdin.

, : , , [ stdin/stdout , ].

The third option is shared memory . I never did this on Windows, but the principle is almost the same as what I used on Linux [and many years ago on OS / 2]: 1. Create a memory area with the given name in the parent process. 2. Children's process opens the same area of ​​memory. 3. Data is stored by the parent process and read by the child process. 4. If necessary, semaphores or the like can be used to complete / readiness / results of readiness / etc.

+1
source

All Articles