核心代码:
发送端代码: HWND hwnd = ::FindWindow(NULL,TEXT("接收端窗口名")); if(hwnd == NULL) { MessageBox(0,TEXT("没找到窗口"),TEXT("ERROR"),MB_OK); } else { // 发送消息 //SendMessage(hwnd,WM_USER+0x1,NULL, (LPARAM)100); PostMessage(hwnd,WM_USER+0x1, NULL, (LPARAM)100); } 接收端代码: switch(uMsg) { case WM_CLOSE: { EndDialog(hDlg,0); break; } case WM_USER+0x1: { DWORD x = wParam; DWORD y = lParam; MessageBox(0,0,0,0); break; } case WM_COMMAND: switch (LOWORD (wParam)) { case IDC_BUTTON_RECV: { return TRUE; } } break ; }
很简单的通信方式!
0则评论给“进程通信 - SendMessage”