您的位置:首页 > 编程语言 > C语言/C++

Windows用户自定义消息实现程序间通信

2012-12-07 18:47 483 查看
这是按照个人需要编写的用户自定义消息程序间通信的发送程序。

程序找到名为“Hand Gesture V1.0"的窗口,将当前点的X, Y坐标发给这个窗口。

当然这个窗口的程序里要加入相应的接收函数。

以下是程序代码,main函数是用来测试的。主要在于send_message函数。

#include "windows.h"
#include <iostream>
//define use message
#define WM_SEND WM_USER+100

//send function
//call this function when sending message to my program
//do not need any modification
void send_message(int send_X, int send_Y)
{

HWND hWnd = ::FindWindowA(NULL,"Hand Gesture V1.0");
if(hWnd != NULL)
{
::SendMessage(hWnd,WM_SEND,(WPARAM)send_X,(LPARAM)send_Y);
}
}

//main function. Just used for testing
int main(int argc, char* argv[])
{
int point_X, point_Y;
while(1){
std::cin >>point_X>>point_Y;
send_message(point_X, point_Y);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐