What is the preferred way of passing data between two applications on the same system?

前端 未结 6 1358
情书的邮戳
情书的邮戳 2020-12-05 06:07

I have an application (A) that needs to launch another application (B). I need to pass data between the applications. I can think of two approaches. The first is to open

6条回答
  •  暖寄归人
    2020-12-05 06:12

    The simplest method (assuming Windows since you mention a DLL) is probably to use CreateProcess and open a pipe to the child process, as described in simplified form here: http://msdn.microsoft.com/en-us/library/ms682499.aspx

    Named Pipes can be an alternative, especially if you aren't in control of the lifetime of all of the processes. http://msdn.microsoft.com/en-us/library/aa365590.aspx

    For simple cases, mailslots may be a sufficient alternative.

    http://msdn.microsoft.com/en-us/library/aa365574.aspx#base.using_a_mailslot_for_ipc

    Here's a longer list of various Interprocess Communication techniques for Windows. http://msdn.microsoft.com/en-us/library/aa365574.aspx

    For something happening locally, using sockets seems sort of overkill. Plus you have to implement your own security mechanism to prevent spoofing attacks, rather than depending on the integrated security mechanism of most of the other IPC methods.

提交回复
热议问题