在可执行文件之间传输数据 [英] Transferring data between executables

查看:158
本文介绍了在可执行文件之间传输数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个用C ++在Windows上编写的可执行文件。我在一个生成一些数据,并希望调用其他可执行文件来处理这些数据。我可以将数据写入文件,然后在其他可执行文件中读取,但这在磁盘I / O方面似乎相当昂贵。什么是更好的方法这样做?这似乎是一个简单的问题,但google只是不帮助!

I have two executables written in C++ on Windows. I generate some data in one, and want to call the other executable to process this data. I could write the data out to a file then read it in the other executable, but that seems rather expensive in terms of disk I/O. What is a better way of doing this? It seems like a simple enough question but google just isn't helping!

我们假设数据是大约100MB,并在生成之前需要发送

Let's say the data is around 100MB, and is generated in its entirety before needing to be sent (i.e. no streaming is needed).

在混合32位和64位进程的时候工作的答案获得奖励点。

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

推荐答案

如果您的进程可以轻松地写入和读取文件,请继续。使用 CreateFile 创建文件,并将其标记为临时&可共享。 Windows使用此提示延迟物理写入,但所有文件语义仍然遵守。由于您的文件只有100 MB,并且正在使用中,Windows几乎肯定能够将其内容完全保存在RAM中。

If your processes can easily write to and read from file, just go ahead. Create the file with CreateFile and mark it as temporary & shareable. Windows uses this hint to delay physical writes, but all file semantics are still obeyed. Since your file is only 100 MB and actively in use, Windows is almost certainly able to keep its contents fully in RAM.

这篇关于在可执行文件之间传输数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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