c语言写简单远程控制源代码(国外英语资料)
c语言写简单远程控制源代码
添加PreTranslateMessage(味精* pMsg)函数可以捕获消息,这里的命令是一个结构体,
# 0 x01定义成功
#定义GetDirInfo 0 x02
#定义ExecFile 0 x03
#定义x04 GetFile 0
#定义x05 PutFile 0
#定义x06 DelFile 0
#定义x07 DelDir 0
#定义CreateDir(
#定义x09 FileInfo 0
#定义GetScreen 0 x10
#定义Getmoses 0 x11
#定义x12 Lbuttond 0
#定义Lbuttonu 0 * 13
#定义Rbuttond 0 x14
#定义Rbuttonu 0连接
#定义LbuttonDd 0 x16时
#定义x17 RbuttonDd 0
#定义x18 MouseWheel 0
#定义x19 KeyDown 0
#定义按键弹起0 x20
#定义x21 Mbd 0
#定义生产部0将
#定义x23 Mbdd 0
typedef结构/ /命令结构
{
int ID;/ /命令ID
字节lparam(BUF_LEN * 2);
int x;/ /鼠标x
int y;/ /鼠标y
短z;/ /滚轮
int关键;/ /键盘
}命令;
BOOL CClientView:PreTranslateMessage(味精* pMsg)
{
//TODO:在这里添加您的专用代码,或者调用基类
命令的命令;
如果(ifconect ! = 0)
{
如果(m_pRecBMPSocket ! = NULL)
m_pRecBMPSocket =零;/ /删除原来的套节字
m_pRecBMPSocket = new CSocket;
m_pRecBMPSocket - > Create();
如果(! m_pRecBMPSocket - >连接(strtemp,2502))
{
/ / m_pRecBMPSocket - >发送(来,30);
弹出窗口(“连接失败”);
删除m_pRecBMPSocket;
m_pRecBMPSocket =零;
}
其他的
{
开关(pMsg - >消息)
{
案例WM_MOUSEMOVE:
memset((char *)命令,0,sizeof(命令));
command.ID = Getmoses;
点lpPoint;
GetCursorPos(&lpPoint);
command.x = lpPoint.x;
命令。y = lpPoint.y;
/ /字符来[256];
/ / sprintf(来,“% d % d”命令。x,command.y);
/ / AfxMessageBox(来);
/ /发送(* m_pRecBMPSocket(char *)命令,sizeof(命令),0);
m_pRecBMPSocket - >发送((char *)命令,sizeof(命令));
打破;
案例WM_KEYDOWN:
memset((char *)命令,0,sizeof(命令));
command.ID = KeyDown;
command.key = pMsg - >按钮;
m_pRecBMPSocket - >发送((char *)命令,sizeof(命令));
打破;
案例WM_KEYUP:
memset((char *)命令,0,sizeof(命令));
command.ID =弹起;
command.key = pMsg - >按钮;
m_pRecBMPSocket - >发送((char *)命令,sizeof(命令));
打破;
案例WM_LBUTTONDOWN:
memset((char *)命令,0,sizeof(命令));
command.ID = Lbuttond;
m_pRecBMPSocket - >发送((char *)命令,sizeof(命令));
打破;
案例WM_LBUTTONUP:
memset((char *)命令,0,sizeof(命令));
command.ID = Lbuttonu;
m_pRecBMPSocket - >发送((char *)命令,sizeof(命令));
打破;
案例WM_RBUTTONDOWN:
memset((char *)命令,0,sizeof(命令));
command.ID = Rbuttond;
m_pRecBMPSocket - >发送((char *)命令,sizeof(命令));
打破;
案例WM_RBUTTONUP:
memset((char *)命令,0,sizeof(命令));
command.ID = Rbuttonu;
m_pRecBMPSocket -