通过命名管道c ++发送对象

时间:2013-12-05 21:21:52

标签: c++ serialization named-pipes

我需要将复杂对象从一个程序传输到另一个程序。我有测试代码,它发送简单的字符串:

.
.
const wchar_t *data = L"*** Some nice string ***";
        DWORD numBytesWritten = 0;
        result = WriteFile(
            pipe, // handle to our outbound pipe
            data, // data to send
            wcslen(data) * sizeof(wchar_t), // length of data to send (bytes)
            &numBytesWritten, // will store actual amount of data sent
            NULL // not using overlapped IO
            );
.
.

这是接收方:

.
.
wchar_t buffer[128];
DWORD numBytesRead = 0;
BOOL result = ReadFile(
pipe,
buffer, // the data from the pipe will be put here
127 * sizeof(wchar_t), // number of bytes allocated
&numBytesRead, // this will store number of bytes actually read
NULL // not using overlapped IO
);
.
.

但是我需要发送一个myIDirect3DDevice9类的实例,而不是字符串,它基本上是修改了IDirect3DDevice9类。我想要序列化是必需的。什么是序列化/发送/反序列化c ++对象最简单,最简单的方法?

0 个答案:

没有答案
相关问题