SendMessage to .NET console application

后端 未结 2 1067
隐瞒了意图╮
隐瞒了意图╮ 2020-12-22 00:22

I have been experimenting with sending messages from two .NET Windows Forms applications using WM_COPYDATA, and it works great.

I would like to know if

相关标签:
2条回答
  • 2020-12-22 00:48

    @tommieb75: XDMessaging is actually my library :) WM_COPYDATA doesn't work for console applications as they don't have a message pump. The library does however include a IOStream based IPC implementation that works for console apps and services. http://thecodeking.github.com/XDMessaging.Net/

    0 讨论(0)
  • 2020-12-22 01:03

    The most common IPC methods (aside from WM_COPYDATA) are memory-mapped files and named pipes. I suggest you check out the latter.

    MSDN has an example of named-pipe communication. Specifically the classes you need to use are NamedPipeServerStream and NamedPipeClientStream, which behave largely like ordinary network streams once they're created.

    The nice thing is that it also works over a network, although you can obviously use it on a single machine as well.

    Setting up an actual Windows message loop in a console application is complicated, to say the least. If you really need to do it, here's a rather long-winded article on the subject. I'd strongly recommend using named pipes instead if all you want to do is transfer data; if you don't actually need to handle standard Windows messages then this isn't going to be worth the effort.

    0 讨论(0)
提交回复
热议问题