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

来源:互联网 发布:电脑麦克风调音软件 编辑:程序博客网 时间:2024/05/17 23:37

这是按照个人需要编写的用户自定义消息程序间通信的发送程序。

程序找到名为“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 modificationvoid 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 testingint main(int argc, char* argv[]){int point_X, point_Y;while(1){std::cin >>point_X>>point_Y;send_message(point_X, point_Y);}}


原创粉丝点击