与 Win32 服务的进程间通信
ControlService API 允许将控制代码发送到 Win32 服务。但是,如果我需要发送(和接收)多个控制代码怎么办?在用户模式 GUI Win32 应用程序和 Win32 服务之间建立通信以交换任意数据的最佳方法是什么? (假设我可以编译服务和应用程序)。该方法应该适用于 Windows 2000 到 Windows 7,并且适用于管理员和标准用户。谢谢!
The ControlService API allows one send a control code to a Win32 service. However, what if I need to send (and receive) more than a control code? What is the best way to establish communication between a user-mode GUI Win32 application and a Win32 service, to exchange arbitrary pieces of data? (Assume I can compile both the service and the application). The method should work from Windows 2000 to Windows 7, and it should work for both the administrators and the standard users. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来好像您打算让服务响应远程请求。为此,您可以使用命名管道,如前所述。然而,命名管道比 TCP 套接字稍微复杂一些。
如果您开始进行 TCP 套接字编程(
socket()
、bind()
、listen()
等),您将能够将这些知识移植到其他平台。It sounds as though you intend for the service to respond to remote requests. For this, you can use named pipes, as already mentioned. Named pipes, however, are a little more complicated than TCP sockets.
If you take up TCP sockets programming (
socket()
,bind()
,listen()
, etc.), you will be able to port that knowledge to other platforms.您几乎可以使用任何 IPC 机制。如果您的服务和应用程序基于 .net,那么最常见的解决方案是使用 WCF。对于本机代码服务和应用程序,一个非常常见的解决方案是命名管道。但哪种选择最好取决于您的具体使用需求。
You can use pretty much any IPC mechanism. If your service and app are .net based, then the most common solution is to use WCF. For native code service and app, a very common solution is a named pipe. But what choice is best depends on your specific usage needs.