Windows 服务通信选项
我正在开发一项服务,该服务将作为系统运行,并将在后台处理长时间运行的任务。我现在需要以任务托盘图标的形式向用户显示一些反馈,我还希望能够从任务托盘图标暂停/恢复任务,因此我的要求是向任一方向发送消息并接收任意消息返回响应的长度数据块。单个请求/响应就可以了,但它需要双向工作。
这是在 Windows 中使用 C++(非 MFC)。
我研究过 MIDL/RPC,因为我过去使用过它,但我需要首先定义一个严格的接口规范,并且不能返回任意长度的数据(据我所知)。
对于我可以用于此目的的库有什么建议吗?
谢谢, J
I'm developing a service which will run as System and will process long-running tasks in the background. I now need to display some feedback to the user in the form of a tasktray icon and I would also like to be able to pause/resume the tasks from the tasktray icon so my requirement is to send a message in either direction and receive an arbitrary length data block back in response. A single request/response would be fine but it needs to work in both directions.
This is using C++ (non-MFC) in Windows.
I've looked at MIDL/RPC as I've used it in the past but I need to define a rigid interface spec first and cannot return arbitrary length data (as far as I am aware).
Are there any suggestions for a library I could use for this?
Thanks,
J
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
COM是Windows中RPC的最佳解决方案。它非常强大并且易于编写。 Raw MS-RPC 也不错。使用两者都可以返回任意长度的数据,请参阅 size_is MIDL 属性:
COM is the best solution for RPC in windows. It is very powerful and easy to write. Raw MS-RPC is good too. With both you can return arbitrary length data, see size_is MIDL attribute:
您可以使用以下任何一种:
编辑 - 根据评论:
一些基于共享内存的解决方案,包括源代码:
You can use any of the following:
EDIT - as per comment:
Some shared memory based solutions including source code: