本例以两个vc dialog application 为例用sendmessage进行两进程间简单通信:
//通过进程名得到进程handle 【程序编程相关:数据流在Filter Graph里的流动】
主要api:findwindow(lpctstr lpclassname, lpctstr lpwindowname ) 【推荐阅读:CPathDialog 类学习方法 】
//the result of the message processing; its value depends on the message sent. 【扩展信息:Win32调试API 注意内存泄漏 】
sendmessage(uint message, wparam wparam = 0, lparam lparam = 0)
主程序 server :其他均为默认.
mfc 建立一dialog 应用程序,工程名字:server
添加一button控件command,并与之对应的函数oncommand
在serverdlg.h里添加自己的消息:#define wm_comm wm_user+10
函数 oncommand 添加代码:
{
cstring str="client"; cwnd *pwnd=cwnd::findwindow(null,str); if(pwnd) pwnd->sendmessage(wm_comm,0,0);//通过sendmessage的后两个参数
... 下一页