Interprocess communication with a Win32 service

2019-07-16 05:12发布

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!

2条回答
贪生不怕死
2楼-- · 2019-07-16 05:32

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.

查看更多
看我几分像从前
3楼-- · 2019-07-16 05:34

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.

查看更多
登录 后发表回答