如何在两个不同的EXE之间建立通信 [英] How to establish the communication between the two Different EXEs

查看:129
本文介绍了如何在两个不同的EXE之间建立通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.如果 A 是一个Windows窗体EXE
2. B 是另一个Windows窗体EXE.
3.必须在此exe之间建立连接,怎么可能

示例:

1.如果我单击exe A 中的一个按钮,则单击事件必须在exe B 中发生.结果将反映到exe A .
2.如果我单击exe B ,则单击事件将在exe A 中发生,结果将反映在EXE B 中. />
那么,如何使用C#.net Windows应用程序.IF建立这两个exe通信,任何人都知道答案.请帮助我.它对我非常有用.

1.If A is a one windows form EXE
2.B is a another Windows Form EXE.
3. Have to Establish the connection between this exes how is it possible

EXAMPLE:

1.IF i click the one button in exe A ,the click event have to be occur in exe B.and the result going to be reflect to exe A.
2.If i Click the exe B the click event will be occur into exe A and result going to be reflect in EXE B.

So How to establish this two exe communication using the C#.net windows Application .IF any one Know the Answer. plz help me.its very useful for me.

推荐答案

消息.两个进程使用消息相互通信.您需要使用远程处理或类似方法.

以下是一些可能的选项.
1)使用基于WCF的进程间通信进行通信
2)通过简单的基于文件的方法进行通信(一个exe进行写操作,其他监视器进行读取)
3)通过套接字进行通信
4)通过Windows消息队列进行通信
Messages. Two processes communicated each other using Messages. You need to use remoting or something like that.

Following are some of the possible options.
1) communicate using WCF based inter process communication
2) communicate via simple file based approach(one exe writes and other monitors and read)
3) communicate via sockets
4) communicate via Windows Message Queues


简短答案:如果您同时拥有.NET程序集或两者的源代码,请尽我所能避免.您有机会将其中之一用作库,并在项目中作为任何库程序集进行引用.这很有可能.

让我们合乎逻辑.您需要在两个应用程序之间建立消息传递/远程通信.假设它们已经在运行.除非您修改其代码,否则您无法添加通信工具.因此,您应该可以访问该代码.如果是这样,则最好将它们集成在一起.始终最好使用单独的线程,而不是单独的进程.

—SA
Short answer: try to avoid it my all means if you have source code for both or both are .NET assemblies. You have a chance to use one of them as a library and reference in your project as any library assembly. This is quite possible.

Let''s be logical. You need to establish messaging/remoting communications between two application. Assume they are already working applications. You cannot add communication facility unless you modify their code. So, you should have access to the code. If so, you better integrate them together. Always better to use separate threads, not separate processes.

—SA


我同意解决方案2,但是您可以使用UI自动化来实现.

UI自动化概述 [
I would agree with Solution 2, however you can use UI Automation to achieve this.

UI Automation Overview[^]

I will be applicable in the case you already have a windows application(From question Exe B), and building a new application which will perform the click (From question Exe A).


这篇关于如何在两个不同的EXE之间建立通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆