基于visual c++之windows核心编程代码分析(48)编程实现远程登录3389

21 篇文章 0 订阅
11 篇文章 0 订阅

 3389端口是Windows 2000(2003) Server 远程桌面的服务端口,可以通过这个端口,用"远程桌面"等连接工具来连接到远程的服务器,如果连接上了,输入系统管理员的用户名和密码后,将变得可以像操作本机一样操作远程的电脑,因此远程服务器一般都将这个端口修改数值或者关闭。
3389端口的关闭:   

首先说明3389端口是windows的远程管理终端所开的端口,它并不是一个木马程序,请先确定该服务是否是你自己开放的。

如果不是必须的,建议关闭该服务。   

win2000 server 开始-->程序-->管理工具-->服务里找到Terminal Services服务项,选中属性选项将启动类型改成手动,并停止该服务。

  win2000 pro 开始-->设置-->控制面板-->管理工具-->服务里找到Terminal Services服务项,选中属性选项将启动类型改成手动,并停止该服务。

  windows xp关闭的方法:在我的电脑上点右键选属性-->远程,将里面的远程协助和远程桌面两个选项框里的勾去掉

我们下面编程实现3389远程登录远程桌面。

[cpp] view plaincopyprint?

  1. #include <windows.h> 
  2. //#include <winuser.h> 
  3. int _stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) 
  4.     HWND MessageBoxHandle,MessageBoxHandle1; 
  5.     POINT pt; 
  6.     char* MstscCommandLine = "mstsc.exe c:\\Default.rdp \/w 1024 \/h 768"
  7.     WinExec(MstscCommandLine,SW_SHOW);  //连接3389 
  8.  
  9.      
  10.     for (int i = 0; i<20;i++) 
  11.         { 
  12.         //查找窗口句柄 
  13.         MessageBoxHandle1 = FindWindow("TSSHELLWND",NULL); 
  14.         MessageBoxHandle = FindWindowEx(MessageBoxHandle1,0,"TSCAXHOST",NULL); 
  15.         MessageBoxHandle = FindWindowEx(MessageBoxHandle,0,"ATL:6A688220",NULL); 
  16.         MessageBoxHandle = FindWindowEx(MessageBoxHandle,0,"UIMainClass",NULL); 
  17.         MessageBoxHandle = FindWindowEx(MessageBoxHandle,0,"UIContainerClass",NULL); 
  18.         MessageBoxHandle = FindWindowEx(MessageBoxHandle,0,"OPWindowClass",NULL); 
  19.         //MessageBoxHandle = FindWindowEx(0,0,0,"Default - 192.168.123.117 - 远程桌面"); 
  20.         if (MessageBoxHandle) 
  21.         { 
  22.             Sleep(2000); 
  23.             //以下发送消息的代码未能测试成功,注释了 
  24.             /*LRESULT returnvalue = SendMessage(MessageBoxHandle,WM_KEYDOWN,VK_F1,1L);
  25.             SendMessage(MessageBoxHandle,WM_CHAR,'I',0);
  26.             Sleep(1000);
  27.             SendMessage(MessageBoxHandle,WM_CHAR,'I',1);
  28.             SendMessage(MessageBoxHandle,WM_CHAR,13,NULL);
  29.             SendMessage(MessageBoxHandle,WM_KEYDOWN,VK_CONTROL,1);*/ 
  30.          
  31.             SetForegroundWindow(MessageBoxHandle1); 
  32.             SendMessage(MessageBoxHandle1,WM_SYSCOMMAND,SC_MAXIMIZE,0); 
  33.             Sleep(1000); 
  34.             mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0); 
  35.             Sleep(1000); 
  36.             mouse_event(MOUSEEVENTF_RIGHTDOWN|MOUSEEVENTF_RIGHTUP,0,0,0,0); 
  37.             Sleep(1000); 
  38.             GetCursorPos(&pt); 
  39.             SetCursorPos(pt.x + 20,pt.y+95); 
  40.             mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0); 
  41.             Sleep(1000); 
  42.             GetCursorPos(&pt); 
  43.             SetCursorPos(pt.x + 164,pt.y); 
  44.             mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0); 
  45.                break
  46.     } 
  47.     Sleep(100); 
  48.     } 
  49.     return 0; 

 

原文地址:http://blog.csdn.net/yincheng01/article/details/7214428

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值