WM_COPYDATA 进程间通信

发送数据:

#include <iostream> #include <windows.h> using namespace std; void main(int argc,TCHAR*argv[]) { //WM_COPYDATA 进程间通信 HWND hWnd = FindWindow(NULL,"Recv"); if(NULL != hWnd) { COPYDATASTRUCT cpd; cpd.dwData = 0; cpd.cbData = strlen("the string to send") + 1; cpd.lpData = (void*)"the string to send"; SendMessage(hWnd,WM_COPYDATA,NULL,(LPARAM)&cpd); } //WM_COPYDATA 进程间通信 }

 

接收数据:

BOOL CRecvDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) { MessageBox((LPCTSTR)pCopyDataStruct->lpData); return CDialog::OnCopyData(pWnd, pCopyDataStruct); }

你可能感兴趣的:(WM_COPYDATA 进程间通信)