Interprocess communication with a Win32 service

↘锁芯ラ 提交于 2019-12-12 20:09:58

问题


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!


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/6918985/interprocess-communication-with-a-win32-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!