c#使用多个远程桌面连接
2011-04-28 15:48
471 查看
写在前面:使用Windows Server服务器的朋友可以找到连接多个远程桌面的功能,但使用Xp操作系统就不行了。远程桌面功能就是使用mstsc这个文件的。在system32文件夹可以找到MSTSCAX.DLL这个动态连接库,这是实现远程连接的主要组件。下载介绍一个用C#编写远程桌面功能,可以连接多个Windows服务器。
源代码
http://www.codeproject.com/KB/cs/RemoteDesktopClient.aspx
你可以到上面的网址了解到更加详细的信息
效果图
下图的左边是一个远程列表,右边是MDI显示区域,可以显示多个远程界面。
下图是这个工具的说明,是使用Vs2008 RTM开发的,.Net版本是3.5Sp1。
源代码分析
相信大家对这个程序最感兴趣的地方是连接mstsc动态链接库的代码。
其中rdpClient 是AxMSTSCLib.AxMsRdpClient 类型对象。
声明如下:
public AxMSTSCLib.AxMsRdpClient rdpClient;
连接远程
public void Connect()//www.elivn.com
{
Status("Starting ...");
rdpClient.Connect();
}
断开远程连接
public void Disconnect()
{
Status("Disconnecting ...");
rdpClient.DisconnectedText = "Disconnected";
if (rdpClient.Connected != 0)
{
rdpClient.Disconnect();
}
}
重新连接远程对象
连接的过程中需要指定服务器,用户名,密码等等。
public void Reconnect(bool hasChanges, bool isFitToWindow)
{
Disconnect();
Status("Waiting for the server to properly disconnect ...");
// wait for the server to properly disconnect
while (rdpClient.Connected != 0)
{
System.Threading.Thread.Sleep(1000);
Application.DoEvents();
}
Status("Reconnecting ...");
if (hasChanges)
{
rdpClient.Server = this._ss.Server;
rdpClient.UserName = this._ss.Username;
rdpClient.AdvancedSettings2.ClearTextPassword = this._ss.Password;
rdpClient.ColorDepth = this._ss.ColorDepth;
this._isFitToWindow = isFitToWindow;
if (isFitToWindow)
{
rdpClient.DesktopWidth = this.rdpClient.Width;
rdpClient.DesktopHeight = this.rdpClient.Height;
}
else
{
rdpClient.DesktopWidth = this._ss.DesktopWidth;
rdpClient.DesktopHeight = this._ss.DesktopHeight;
}
rdpClient.FullScreen = this._ss.Fullscreen;
}
Connect();
}
在连接的过程中,会使用大量Com接口函数。
这一程序,可以作为.Net实现远程桌面的重要参考。
源代码
http://www.codeproject.com/KB/cs/RemoteDesktopClient.aspx
你可以到上面的网址了解到更加详细的信息
效果图
下图的左边是一个远程列表,右边是MDI显示区域,可以显示多个远程界面。
下图是这个工具的说明,是使用Vs2008 RTM开发的,.Net版本是3.5Sp1。
源代码分析
相信大家对这个程序最感兴趣的地方是连接mstsc动态链接库的代码。
其中rdpClient 是AxMSTSCLib.AxMsRdpClient 类型对象。
声明如下:
public AxMSTSCLib.AxMsRdpClient rdpClient;
连接远程
public void Connect()//www.elivn.com
{
Status("Starting ...");
rdpClient.Connect();
}
断开远程连接
public void Disconnect()
{
Status("Disconnecting ...");
rdpClient.DisconnectedText = "Disconnected";
if (rdpClient.Connected != 0)
{
rdpClient.Disconnect();
}
}
重新连接远程对象
连接的过程中需要指定服务器,用户名,密码等等。
public void Reconnect(bool hasChanges, bool isFitToWindow)
{
Disconnect();
Status("Waiting for the server to properly disconnect ...");
// wait for the server to properly disconnect
while (rdpClient.Connected != 0)
{
System.Threading.Thread.Sleep(1000);
Application.DoEvents();
}
Status("Reconnecting ...");
if (hasChanges)
{
rdpClient.Server = this._ss.Server;
rdpClient.UserName = this._ss.Username;
rdpClient.AdvancedSettings2.ClearTextPassword = this._ss.Password;
rdpClient.ColorDepth = this._ss.ColorDepth;
this._isFitToWindow = isFitToWindow;
if (isFitToWindow)
{
rdpClient.DesktopWidth = this.rdpClient.Width;
rdpClient.DesktopHeight = this.rdpClient.Height;
}
else
{
rdpClient.DesktopWidth = this._ss.DesktopWidth;
rdpClient.DesktopHeight = this._ss.DesktopHeight;
}
rdpClient.FullScreen = this._ss.Fullscreen;
}
Connect();
}
在连接的过程中,会使用大量Com接口函数。
这一程序,可以作为.Net实现远程桌面的重要参考。
相关文章推荐
- c#使用多个远程桌面连接
- 用windows远程连接linux桌面(使用tightvnc或者tigervnc)
- C# 使用oledb 方式连接本地或者远程oracel 数据库的方式
- 通过VNC Viewer使用VMware虚拟机的远程桌面连接
- C#使用RDP远程桌面
- 使用rdesktop远程连接Windows桌面
- 在远程桌面连接中使用命令行参数
- 如何使用 SPICE client (virt-viewer) 来连接远程虚拟机桌面?
- 远程桌面连接的使用方法
- 在远程桌面连接中,可以使用哪些快捷键?
- windows 2003 远程桌面连接3389证书使用1
- Win7使用附件中的远程桌面连接Ubuntu 图形界面(xrdp方法)
- 树莓派远程桌面连接-使用Windows自带远程桌面连接工具
- windows使用mstsc远程桌面时连接本地磁盘和U盘的方法
- 使用plink以及ssh转发连接到局域网内的远程桌面或其它端口
- [原创]使用空密码远程桌面连接
- VNC远程连接Linux桌面的安装和使用
- Windows下使用VNC连接CentOS7远程桌面
- XP系统远程桌面连接使用administrator账号空密码登录
- Windows下使用VNC连接CentOS7远程桌面