3389端口是Windows 2000(2003) Server 远程桌面的服务端口,可以通过这个端口,用"远程桌面"等连接工具来连接到远程的服务器,如果连接上了,输入系统管理员的用户名和密码后,将变得可以像操作本机一样操作远程的电脑,因此远程服务器一般都将这个端口修改数值或者关闭。
3389端口的关闭:
首先说明3389端口是windows的远程管理终端所开的端口,它并不是一个木马程序,请先确定该服务是否是你自己开放的。
如果不是必须的,建议关闭该服务。
win2000 server 开始-->程序-->管理工具-->服务里找到Terminal Services服务项,选中属性选项将启动类型改成手动,并停止该服务。
win2000 pro 开始-->设置-->控制面板-->管理工具-->服务里找到Terminal Services服务项,选中属性选项将启动类型改成手动,并停止该服务。
windows xp关闭的方法:在我的电脑上点右键选属性-->远程,将里面的远程协助和远程桌面两个选项框里的勾去掉
我们下面编程实现3389远程登录远程桌面。
[cpp] view plaincopyprint?
- #include <windows.h>
- //#include <winuser.h>
- int _stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
- {
- HWND MessageBoxHandle,MessageBoxHandle1;
- POINT pt;
- char* MstscCommandLine = "mstsc.exe c:\\Default.rdp \/w 1024 \/h 768";
- WinExec(MstscCommandLine,SW_SHOW); //连接3389
- for (int i = 0; i<20;i++)
- {
- //查找窗口句柄
- MessageBoxHandle1 = FindWindow("TSSHELLWND",NULL);
- MessageBoxHandle = FindWindowEx(MessageBoxHandle1,0,"TSCAXHOST",NULL);
- MessageBoxHandle = FindWindowEx(MessageBoxHandle,0,"ATL:6A688220",NULL);
- MessageBoxHandle = FindWindowEx(MessageBoxHandle,0,"UIMainClass",NULL);
- MessageBoxHandle = FindWindowEx(MessageBoxHandle,0,"UIContainerClass",NULL);
- MessageBoxHandle = FindWindowEx(MessageBoxHandle,0,"OPWindowClass",NULL);
- //MessageBoxHandle = FindWindowEx(0,0,0,"Default - 192.168.123.117 - 远程桌面");
- if (MessageBoxHandle)
- {
- Sleep(2000);
- //以下发送消息的代码未能测试成功,注释了
- /*LRESULT returnvalue = SendMessage(MessageBoxHandle,WM_KEYDOWN,VK_F1,1L);
- SendMessage(MessageBoxHandle,WM_CHAR,'I',0);
- Sleep(1000);
- SendMessage(MessageBoxHandle,WM_CHAR,'I',1);
- SendMessage(MessageBoxHandle,WM_CHAR,13,NULL);
- SendMessage(MessageBoxHandle,WM_KEYDOWN,VK_CONTROL,1);*/
- SetForegroundWindow(MessageBoxHandle1);
- SendMessage(MessageBoxHandle1,WM_SYSCOMMAND,SC_MAXIMIZE,0);
- Sleep(1000);
- mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0);
- Sleep(1000);
- mouse_event(MOUSEEVENTF_RIGHTDOWN|MOUSEEVENTF_RIGHTUP,0,0,0,0);
- Sleep(1000);
- GetCursorPos(&pt);
- SetCursorPos(pt.x + 20,pt.y+95);
- mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0);
- Sleep(1000);
- GetCursorPos(&pt);
- SetCursorPos(pt.x + 164,pt.y);
- mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0);
- break;
- }
- Sleep(100);
- }
- return 0;
- }
原文地址:http://blog.csdn.net/yincheng01/article/details/7214428