开发者

How do I set up a named pipe between .NET and MFC?

开发者 https://www.devze.com 2023-02-04 02:37 出处:网络
How do I set up named p开发者_开发技巧ipe between a .NET (specifically WPF) application and an MFC application running in the background?I need to provide synchronous and asynchronous messaging sendin

How do I set up named p开发者_开发技巧ipe between a .NET (specifically WPF) application and an MFC application running in the background? I need to provide synchronous and asynchronous messaging sending XML instances. Is there a way to use a call back architecture?


In the MFC application: I don't think there are any MFC classes specifically to help with named pipes, but the Windows Named Pipes API is not too difficult, or you could look to open source/shareware classes for higher level abstractions (for example here)

In the .NET application, the types in the System.IO.Pipes namespace provide a nice stream abstraction over a named pipe which is fairly straightforward to use.

Decisions you will have to make include:

  1. Which application is the pipe server, responsible for creating the pipe and listening for the other application (pipe client) to connect.
  2. Can you work directly with the message-streaming mode provided by the OS (each write to the pipe is deemed one message), or do you need to build your own message framing over the pipe byte-stream.

Duplex operation is supported, so you can build "callback architecture" over the pipe messaging if you want to.

Windows Communication Framework provides a Named Pipe transport binding. But this won't be useful to you even on the WPF application side unless you are up for reimplementing on the MFC side a host of partly-documented Microsoft protocols layered on top of the raw pipe communication (you can read more on this on my blog if you are interested).

0

精彩评论

暂无评论...
验证码 换一张
取 消