两个独立的exe程序之间如何完成通信呢?首先想到的办法是利用生成文件的方法,即,发送端在某个目录下生
成一个文件,包含要发送的消息,接收端从这个目录中读取文件且获取消息。这个方法也能实现通信,但是总感觉有
点多此一举。能不能让两个exe程序直接进行通信,发送消息呢?
答案是肯定的!而且还有好几种方法。1 发送消息传递 2 共享内存传递 3 使用COM进程外服务器 ...
这篇文章主要说明一下,如何利用发送消息使两个exe完成通信。其他两个方法感兴趣可以搜索下,都可以找到相应
的demo,这里就不再另加说明了。
这次的demo分为两个部分,发送端和接收端。顾名思义分别负责发送消息和接收消息。
添加这两个窗体
发送端代码:
?1234567891011121314151617181920212223242526272829303132333435363738 | //WM_COPYDATA消息所要求的数据结构 public struct CopyDataStruct { java spaces" style="margin: 0px !important; padding: 0px !important; outline: 0px !important; border-radius: 0px !important; border: 0px currentColor !important; left: auto !important; top: auto !important; width: auto !important; height: auto !important; text-align: left !important; right: auto !important; bottom: auto !important; line-height: 1.1em !important; overflow: visibl |