社区
C++ 语言
帖子详情
关于C++的一个简单问题
xc_zzq
2013-10-27 04:38:06
我新学C++,想问一下如果两个程序同时运行,比如在A程序中输入一个数,让它在B程序中显示出来,这个应该怎么操作?
...全文
150
5
打赏
收藏
关于C++的一个简单问题
我新学C++,想问一下如果两个程序同时运行,比如在A程序中输入一个数,让它在B程序中显示出来,这个应该怎么操作?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
max_min_
2013-10-27
打赏
举报
回复
进程间通信(IPC) 没别的了!
turing-complete
2013-10-27
打赏
举报
回复
socket比较通用,两个进程可以不在同一台机器上,写代码可能会稍多。当然,一些消息队列也支持跨机器操作,只不过是高层次的socket而已。 如果,在同一台机器上,可以用
共享内存
。
金丝龙麟闪电劈
2013-10-27
打赏
举报
回复
(1)发送消息 使用FindWindow找到窗口,然后发送WM_COPYDATA消息,字符串附加到COPYDATASTRUCT 结构体 LRESULT copyDataResult; CWnd *pOtherWnd = CWnd::FindWindow(NULL, strWindowTitle); if (pOtherWnd) { COPYDATASTRUCT cpd; cpd.dwData = 0; cpd.cbData = strDataToSend.GetLength(); cpd.lpData = (void*)strDataToSend.GetBuffer(cpd.cbData); copyDataResult = pOtherWnd->SendMessage(WM_COPYDATA, (WPARAM)AfxGetApp()->m_pMainWnd->GetSafeHwnd(), (LPARAM)&cpd); strDataToSend.ReleaseBuffer(); // copyDataResult has value returned by other app } else { AfxMessageBox("Unable to find other app."); } (2)添加消息 The other app should handle the WM_COPYDATA message in the following manner BEGIN_MESSAGE_MAP(CMyWnd, CWnd) //{{AFX_MSG_MAP(CMyWnd) ... ON_WM_COPYDATA() ... //}}AFX_MSG_MAP END_MESSAGE_MAP() (3)消息处理 BOOL CMyWnd::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) { CString strRecievedText = (LPCSTR) (pCopyDataStruct->lpData); return CMyWnd::OnCopyData(pWnd, pCopyDataStruct); }
derekrose
2013-10-27
打赏
举报
回复
两个程序同时运行 你先说说是怎么实现的
金丝龙麟闪电劈
2013-10-27
打赏
举报
回复
如果是窗口应用程序的话,直接发送WM_COPYDATA消息在进程间传送数据
Our Journey of Dalian Ends(2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 J)
Problem Description Life is a journey, and the road we travel has twists and turns, which sometimes lead us to unexpected places and unexpected people. Now our journey of Dalian ends. To be careful...
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 - J Our Journey of Dalian Ends(最小费用最大流)
Life is a journey, and the road we travel has twists and turns, which sometimes lead us to unexpected places and unexpected people. Now our journey of Dalian ends. To be carefully considered are the
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 J. Our Journey of Dalian Ends [网络流]
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 J. Our Journey of Dalian Ends [网络流]
【2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛】 J Our Journey of Dalian Ends 【拆点费用流】
Life is a journey, and the road we travel has twists and turns, which sometimes lead us to unexpected places and unexpected people.Now our journey of Dalian ends. To be carefully considered are the fol
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 J.Our Journey of Dalian Ends【最小费用最大流】
Life is a journey, and the road we travel has twists and turns, which sometimes lead us to unexpected places and unexpected people. Now our journey of Dalian ends. To be carefully considered are the
C++ 语言
65,211
社区成员
250,514
社区内容
发帖
与我相关
我的任务
C++ 语言
C++ 语言相关问题讨论,技术干货分享,前沿动态等
复制链接
扫一扫
分享
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
请不要发布与C++技术无关的贴子
请不要发布与技术无关的招聘、广告的帖子
请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下
试试用AI创作助手写篇文章吧
+ 用AI写文章