c# 创建一个只接收消息的窗口
/// <summary> /// WM_COPYDATA消息,进程间传输信息专用结构 /// </summary> public struct COPYDATASTRUCT { public UINT64 dwData; public int cbData; public IntPtr lpData; } public class NotifierNativeWindow : NativeWindow { const string WindowName = "MessageOnlyWindow"; uint WM_COPYDATA = 0x4A; public NotifierNativeWindow() { CreateParams cp = new CreateParams(); cp.Style = 0; cp.ExStyle = 0; cp.ClassStyle = 0; cp.Caption = WindowName; if (Environment.OSVersion.Platform == PlatformID.Win32NT) cp.Parent = (IntPtr)(-3); CreateHandle(cp); } protected override unsafe void WndProc(ref Message m) { if (m.Msg == WM_COPYDATA) { var obj = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); } base.WndProc(ref m); } }