在流程之间共享类实例的方法 [英] Methods of sharing class instances between processes

查看:75
本文介绍了在流程之间共享类实例的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个C ++类,我需要在至少两个Windows进程之间共享一个实例。

I have written a C++ class that I need to share an instance of between at least two windows processes. What are the various ways to do this?

最初,我查看了#pragma data_seg 令我失望的是,我意识到它不适用于类或分配给堆的任何东西。

Initially I looked into #pragma data_seg only to be disappointed when I realised that it will not work on classes or with anything that allocates on the heap.

该类的实例必须可以通过dll访问,因为现有的完整应用程序已经在使用该dll。

The instance of the class must be accessible via a dll because existing, complete applications already use this dll.

推荐答案

您可以潜在地使用内存映射文件以在进程之间共享数据。如果需要在对象上调用函数,则必须使用COM或类似的东西,或者必须实现自己的RPC协议。

You can potentially use memory-mapped files to share data between processes. If you need to call functions on your object, you'd have to use COM or something similar, or you'd have to implement your own RPC protocol.

这篇关于在流程之间共享类实例的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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