进程间使用copydata完成通信
进程间通信最简单的方式就是发送WM_COPYDATA消息。 发送WM_COPYDATA消息: SendMessage(接收窗口句柄, WM_COPYDATA, (WPARAM)发送窗口句柄, (LPARAM)&CopyData); 其中的CopyData为COPYDATASTRUCT结构类型,该结构定义如下: typedef struct tagCOPYDATASTRUCT { DWORD dwData; // Specifies data to be passed to the receiving application. DWORD cbData; //Specifies the size, in bytes, of the data pointed to by the lpData member. PVOID lpData; // Pointer to data to be passed to the receiving application. can be NULL. } COPYDATASTRUCT, *PCOPYDATASTRUCT; 接收WM_COPYDATA消息: 只要用COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT*)lParam;就可以了。接收方应认为这些数据是只读的。 由于发送方在接收方处理WM_COPYDATA消息完毕前都是处于等待中,所以接收方应当尽快处理WM_COPYDATA消息。 本资源中user1需要先发送,携带有主窗口句柄,然后recv根据窗口句柄回复,详情见代码
下载地址
用户评论
还行吧!!!!!可以勉强凑活使用!