白开水易拉罐 发表于 2012-12-19 21:10:01

WPF通过消息机制实现进程间通信(IPC)

<div id="cnblogs_post_body">接收端代码:
<div class="cnblogs_code">      public struct CopyDataStruc      {            public IntPtr dwData;            public int cbData;// 字符串长度                        public string lpData; // 字符串      }      private void Window_Loaded(object sender, RoutedEventArgs e)      {            (PresentationSource.FromVisual(this) as HwndSource).AddHook(new HwndSourceHook(this.WndProc));      }      IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)      {            if (msg == MessageHelper.WM_DOWNLOAD_COMPLETED)            {                //CopyDataStruct cds = (CopyDataStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(lParam, typeof(CopyDataStruct));                MessageBox.Show("I got it!");            }            return hwnd;      }
页: [1]
查看完整版本: WPF通过消息机制实现进程间通信(IPC)