c语言写简单远程控制源代码

上传人:woxinch****an2018 文档编号:38643604 上传时间:2018-05-05 格式:DOCX 页数:8 大小:7.44KB
返回 下载 相关 举报
c语言写简单远程控制源代码_第1页
第1页 / 共8页
c语言写简单远程控制源代码_第2页
第2页 / 共8页
c语言写简单远程控制源代码_第3页
第3页 / 共8页
c语言写简单远程控制源代码_第4页
第4页 / 共8页
c语言写简单远程控制源代码_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《c语言写简单远程控制源代码》由会员分享,可在线阅读,更多相关《c语言写简单远程控制源代码(8页珍藏版)》请在金锄头文库上搜索。

1、添加PreTranslateMessage(MSG* pMsg) 函数可以捕获消息,这里的COMMAND是一个结构体,#define Success 0x01 #define GetDirInfo 0x02 #define ExecFile 0x03 #define GetFile 0x04 #define PutFile 0x05 #define DelFile 0x06 #define DelDir 0x07 #define CreateDir 0x08 #define FileInfo 0x09 #define GetScreen 0x10 #define Getmoses 0x11 #

2、define Lbuttond 0x12 #define Lbuttonu 0x13 #define Rbuttond 0x14 #define Rbuttonu 0x15 #define LbuttonDd 0x16 #define RbuttonDd 0x17 #define MouseWheel 0x18 #define KeyDown 0x19 #define KeyUp 0x20 #define Mbd 0x21 #define Mbu 0x22 #define Mbdd 0x23 typedef struct /命令结构 int ID; /命令ID BYTE lparamBUF_L

3、EN*2; int x; /鼠标xint y; /鼠标y short z; /滚轮 int key; /键盘COMMAND;BOOL CClientView:PreTranslateMessage(MSG* pMsg) / TODO: Add your specialized code here and/or call the base class COMMAND command; if (ifconect!=0) if(m_pRecBMPSocket!=NULL) m_pRecBMPSocket=NULL;/删除原来的套节字m_pRecBMPSocket=new CSocket; m_pRe

4、cBMPSocket-Create(); if(!m_pRecBMPSocket-Connect(strtemp,2502) /m_pRecBMPSocket-Send(buf1,30); MessageBox(“连接失败“);delete m_pRecBMPSocket ; m_pRecBMPSocket=NULL; else switch (pMsg-message) case WM_MOUSEMOVE: memset(char*) command.ID=Getmoses; POINT lpPoint; GetCursorPos( command.x=lpPoint.x; command.

5、y= lpPoint.y; /char buf1256; /sprintf(buf1,“%d %d“,command.x, command.y); / AfxMessageBox(buf1); / send(*m_pRecBMPSocket,(char*) m_pRecBMPSocket-Send(char*) break; case WM_KEYDOWN: memset(char*) command.ID=KeyDown; command.key=pMsg-wParam; m_pRecBMPSocket-Send(char*) break; case WM_KEYUP: memset(cha

6、r*) command.ID=KeyUp; command.key=pMsg-wParam; m_pRecBMPSocket-Send(char*) break;case WM_LBUTTONDOWN: memset(char*)command.ID=Lbuttond; m_pRecBMPSocket-Send(char*) break;case WM_LBUTTONUP: memset(char*) command.ID=Lbuttonu; m_pRecBMPSocket-Send(char*) break;case WM_RBUTTONDOWN: memset(char*) command

7、.ID=Rbuttond; m_pRecBMPSocket-Send(char*) break;case WM_RBUTTONUP: memset(char*) command.ID=Rbuttonu; m_pRecBMPSocket-Send(char*) break;case WM_LBUTTONDBLCLK: memset(char*) command.ID=LbuttonDd; m_pRecBMPSocket-Send(char*) break;case WM_RBUTTONDBLCLK: memset(char*) command.ID=RbuttonDd; m_pRecBMPSoc

8、ket-Send(char*) break;case WM_MOUSEWHEEL: memset(char*) command.ID=MouseWheel; command.z=(short)HIWORD(pMsg-wParam); m_pRecBMPSocket-Send(char*) /AfxMessageBox(buf1); break; case WM_MBUTTONDOWN: memset(char*) command.ID=Mbd;command.z=(short)HIWORD(pMsg-wParam); m_pRecBMPSocket-Send(char*) break;case

9、 WM_MBUTTONUP: memset(char*) command.ID=Mbu; command.z=(short)HIWORD(pMsg-wParam); m_pRecBMPSocket-Send(char*) break;case WM_MBUTTONDBLCLK: memset(char*) command.ID=Mbdd; command.z=(short)HIWORD(pMsg-wParam); m_pRecBMPSocket-Send(char*) break; return CView:PreTranslateMessage(pMsg); 在客户端节接收命令:void C

10、EmployerSocket:OnReceive(int nErrorCode) / TODO: Add your specialized code here and/or call the base classCSocket:OnReceive(nErrorCode);COMMAND command; BYTE *buf=(BYTE *)malloc(5120); int rec=Receive(buf,5120,0); /MsgTyperec-1=0; memcpy( / AfxMessageBox(MsgType); switch(command.ID) case B: m_pDlg-S

11、endBITMAP(this); /接收类型为b /发送bitmap结构 break; case D: m_pDlg-SendBitData(this);/发送bitmap的数据 break; case Getmoses: GetMosesProc(command); break;case Lbuttond: LbuttondProc(command); break;case Lbuttonu: LbuttonuProc(command); break;case Rbuttond: RbuttondProc(command); break;case Rbuttonu: RbuttonuProc

12、(command); break;case LbuttonDd: LbuttonDdProc(command); break;case RbuttonDd: RbuttonDdProc(command); break; case Mbd: MbdProc(command); break;case Mbu:MbuProc(command); break;case Mbdd: MbddProc(command); break;case MouseWheel: MouseWheelProc(command); break;case KeyDown: KeyDownProc(command); bre

13、ak;case KeyUp: KeyUpProc(command); break; default: break; DWORD GetMosesProc (COMMAND command) char buf1256; sprintf(buf1,“%d %d“,command.x, command.y); / AfxMessageBox(buf1); SetCursorPos(command.x, command.y); return 0; DWORD LbuttondProc(COMMAND command) mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);

14、 return 0; DWORD LbuttonuProc(COMMAND command) mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); return 0; DWORD RbuttondProc(COMMAND command) mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); return 0; DWORD RbuttonuProc(COMMAND command) mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0); return 0; DWORD LbuttonDdProc(COMM

15、AND command) mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); return 0; DWORD RbuttonDdProc(COMMAND command) mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_RIGH

16、TUP,0,0,0,0); mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0); return 0; DWORD MbdProc(COMMAND command) mouse_event(MOUSEEVENTF_MIDDLEDOWN,0,0,0,0); return 0; DWORD MbuProc(COMMAND command) mouse_event(MOUSEEVENTF_MIDDLEUP,0,0,0,0); return 0; DWORD MbddProc(COMMAND command) /AfxMessageBox(“dd“);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 高中教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号