在窗口应用程序之间进行进程通讯,最为方便的方法就是使用WM_COPYDATA消息。
当软件开发越来越多功能时,就会导致每个软件代码急剧上升,从而把系统变得越来越复杂。
这时,我们应对的办法,就是把程序功能拆分。
把程序功能分开之后,这样就可以把程序的代码控制在合适的范围内。
提高了开发人员的效率,减少了系统的复杂度。
但是程序与程序之间,还需要协同工作,那么就需要相互进行通讯。
下面就是使用消息通讯的例子,
发送端的程序:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp20_sendcopydata
{
public partial class Form1 : Form
{
// 导入 Windows API 函数
[DllImport("user32.dll", CharSet &#