Windows远程桌面客户端
2021-04-07 12:25
标签:tools scree end targe rect sys setting this ext 1、注册控件:regsvr32 C:\Windows\System32\mstscax.dll。 2、添加RDP Control控件到工具箱中。我选择的RDP Client Control (redistributable) - version 9 3、在VS项目中引用C:\Windows\System32\mstscax.dll 4、RdpTabPage类 5、主窗体 6、程序下载地直址 https://pan.baidu.com/s/1Fcolic2QAcNANJszscVUjg Windows远程桌面客户端 标签:tools scree end targe rect sys setting this ext 原文地址:https://www.cnblogs.com/zhangwc/p/9110589.htmlusing System;
using System.Windows.Forms;
namespace RdpClient
{
public class RdpTabPage : TabPage
{
AxMSTSCLib.AxMsRdpClient9 rdpc = null;
protected override void OnCreateControl()
{
rdpc = new AxMSTSCLib.AxMsRdpClient9();
rdpc.OnDisconnected += new AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEventHandler(rdpc_OnDisconnected);
this.Controls.Add(rdpc);
rdpc.Dock = DockStyle.Fill;
base.OnCreateControl();
}
void rdpc_OnDisconnected(object sender, AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEvent e)
{
((TabControl)this.Parent).TabPages.Remove(this);
}
public void Disconnect()
{
try
{
if (rdpc.Connected == 1)
{
rdpc.Disconnect();
}
}
catch (Exception) { }
}
private void SetRdpClientProperties(RdpInfo info)
{
rdpc.Server = info.MachineName;
rdpc.UserName = info.UserName;
rdpc.Domain = "";
rdpc.AdvancedSettings9.RDPPort = info.RdpPort;
rdpc.AdvancedSettings9.ClearTextPassword = info.Password;
rdpc.AdvancedSettings9.RedirectDrives = true;
rdpc.AdvancedSettings9.RedirectPrinters = true;
rdpc.AdvancedSettings9.RedirectSmartCards = true;
rdpc.AdvancedSettings9.ConnectToServerConsole = true;
rdpc.ColorDepth = 32;
rdpc.Dock = DockStyle.Fill;
}
public void Connect(RdpInfo info)
{
SetRdpClientProperties(info);
rdpc.Connect();
}
}
}
using System;using System.Windows.Forms;
namespace RdpClient
{
public partial class Form_Main : Form
{
#region 构造
public Form_Main()
{
InitializeComponent();
}
#endregion
#region 方法
///