发送端代码: void CProcessADlg::OnSendMessage() { // TODO: Add your control notification handler code here //找到接收消息的窗口(窗口名为Receiver) CString str="ProcessB"; CWnd *pWnd=CWnd::FindWindow(NULL,str); CString m_Msg1; GetDlgItem(IDC_EDIT1)->GetWindowText(m_Msg1); if(pWnd) { COPYDATASTRUCT buf; char * s=new char[m_Msg1.GetLength()]; //m_Msg1为CString类型的变量 s=m_Msg1.GetBuffer(0); buf.cbData=strlen(s)+1; buf.lpData=s; pWnd->SendMessage(WM_COPYDATA,0,(LPARAM)&buf); //传送大量数据要用WM_COPYDATA消息 } } 接收端代码: 接收端重载ON_WM_COPYDATA消息映射函数(下面是手工所要加的,你最好还是用ClassWizard) afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct); ON_WM_COPYDATA()/*消息映射*/ BOOL CProcessBDlg::OnCopyData(CWnd* pWnd,COPYDATASTRUCT* pCopyDataStruct) { //AfxMessageBox((LPCSTR)(pCopyDataStruct->lpData));/*利用对话框表示收到消息*/ GetDlgItem(IDC_EDIT1)->SetWindowText((LPCSTR)(pCopyDataStruct->lpData)); return CWnd::OnCopyData(pWnd,pCopyDataStruct); }