C#中的IPC,将文本从一个exe发送到另一个exe

我想从WPF应用程序的文本框向打开的记事本发送消息。 点击文本框旁边的按钮后,我想将内容写入记事本,我的意思是。

如何在两个不同的应用程序之间发送消息?

[DllImport("user32.dll", EntryPoint = "FindWindowEx")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam); private static void DoSendMessage(string message) { Process notepad = Process.Start(new ProcessStartInfo("notepad.exe")); notepad.WaitForInputIdle(); if (notepad != null) { IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null); SendMessage(child, 0x000C, 0, message); } } 

要在您控制的两个应用程序之间发送数据,可以使用NamedPipeClientStream和NamedPipeServerStream