Saturday, May 01, 2010

RDP Clients

I founded a while ago mRemote which helps me to have only one tool to connect multiple servers without to enter any time the password. Now I found an additional Remote Desktop Manager tool on codeproject - Palantir and I was curious what are the main parts to manage a remote desktop connection.

Therefore I have stripped out the intersting part:


private AxMSTSCLib.AxMsRdpClient4 rdpc = null;

protected override void OnCreateControl()
{
rdpc = new AxMSTSCLib.AxMsRdpClient4();
rdpc.OnDisconnected += new AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEventHandler(rdpc_OnDisconnected);
this.Controls.Add(rdpc);
rdpc.Dock = DockStyle.Fill;
base.OnCreateControl();
}

public void Disconnect()
{
try
{
if (rdpc.Connected == 1)
{
rdpc.Disconnect();
}
}
catch (Exception)
{ }
}

private void SetRdpClientProperties(Machine parMachine)
{
rdpc.Server = parMachine.MachineName;
rdpc.UserName = parMachine.UserName;
rdpc.Domain = parMachine.DomainName;
if (parMachine.Password != "")
{
rdpc.AdvancedSettings5.ClearTextPassword = parMachine.Password;
}
rdpc.AdvancedSettings5.RedirectDrives = parMachine.ShareDiskDrives;
rdpc.AdvancedSettings5.RedirectPrinters = parMachine.SharePrinters;
rdpc.ColorDepth = (int)parMachine.ColorDepth;
rdpc.Dock = DockStyle.Fill;

}

public void Connect(Machine parMachine)
{
SetRdpClientProperties(parMachine);
rdpc.Connect();
}

public void ConnectViaConsole(Machine parMachine)
{
rdpc.AdvancedSettings5.ConnectToServerConsole = true;
SetRdpClientProperties(parMachine);

rdpc.Connect();
}



The AxMSTSCLib.AxMsRdpClient4 and AxInterop.MSTSCLib dll's can be downloaded from codeproject - Palantir directly or from the following location as a zip file:
http://www.ronischuetz.com/download/Interop.MSTSCLib_and_AxInterop.MSTSCLib.zip


Update: additional description how you add the dll's directly: http://www.codeproject.com/KB/cs/RemoteDesktop_CSharpNET.aspx

No comments:

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge