先上图:
我们可以调用ms的两个组件来进行远程桌面的连接与管理,这两个组件分别是:
AxInterop.MSTSCLib.dll
Interop.MSTSCLib.dll
在(http://download.csdn.net/source/2652181)有示例代码
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RemoteDesktopClient
{
public partial class frmMain : Form
{
private AxMSTSCLib.AxMsRdpClient rdpc = null;
public frmMain()
{
InitializeComponent();
rdpc = new AxMSTSCLib.AxMsRdpClient();
rdpc.Dock = DockStyle.Fill;
this.tabPage1.Controls.Add(rdpc);
}
private void btnConnect_Click(object sender, EventArgs e)
{
try
{
rdpc.Server = this.txtServer.Text; //远程桌面的IP地址或者域名
rdpc.Domain = ""; //远程服务器所在的域
rdpc.UserName = this.txtUserName.Text; //系统用户名
rdpc.AdvancedSettings2.ClearTextPassword = txtPassword.Text; //系统登录密码
rdpc.AdvancedSettings2.RedirectDrives = true;
rdpc.AdvancedSettings2.RedirectPrinters = true;
rdpc.ColorDepth = 32; //8,16,24,32
rdpc.DesktopHeight = this.tabPage1.Height-50;
rdpc.DesktopWidth = this.tabPage1.Width-50;
rdpc.Connect();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnDisconnect_Click(object sender, EventArgs e)
{
if (rdpc.Connected == 1)
rdpc.Disconnect();
}
}
}