开发者

How can two applications/processes communicate by COM?

开发者 https://www.devze.com 2023-01-14 21:06 出处:网络
I\'m looking for a way to ease the difficulty transferring data from one application/process to another.

I'm looking for a way to ease the difficulty transferring data from one application/process to another.

It's said to be better than UDP or TCP for communicating by processes in the same OS(windows xp here) .

Can you provide some core code that i开发者_Python百科llustrate this?


take a look at boost.Interprocess to get an easy way to do communication


Well, yes, COM supports remote procedure calls to an out-of-process COM server. You make the call from the client, it runs in another process as though it was called inside that process. A code snippet doesn't make much sense because it looks exactly like a regular function call.

There's a fair amount of plumbing and configuration you have to take care of to make that work. You typically need a proxy/stub DLL that helps to marshal the arguments of the function call. They are normally auto-generated from the IDL you write that describes the interfaces. If the arguments you pass are 'unusual' then you may need to write a custom marshaller. That's usually easily avoided by not passing opaque pointers or variable sized chunks of data.

Visual Studio can get a lot of that stuff done automatically, ATL is very helpful. Doing something wrong unintentionally is definitely a lot harder to trouble-shoot. Expect several months to get up to speed on this if you've never done it before. Getting good learning material can be difficult, this is getting obsolete. This kind of stuff is done in managed environments these days. Much easier to auto-generate the required proxies.


In my project I decided to use named pipes for inter-process communication.

  • Interprocess Communications
  • Named pipe server using overlapped I/O
  • Named pipe client
0

精彩评论

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

关注公众号