Click here to Skip to main content
6,596,602 members and growing! (23,445 online)
Email Password   helpLost your password?
Languages » C# » Applications     Intermediate License: The Code Project Open License (CPOL)

Palantir - Remote Desktop Manager

By Isil Orhanel

Palantir is an application that allows users to manage remote desktop connections in one window. It also allows users to save existing connections for later use.
C# 2.0.NET 2.0, Win2K, WinXP, Win2003, VistaVS2005, Architect, DBA, Dev
Posted:1 Aug 2007
Updated:6 Aug 2007
Views:77,014
Bookmarked:155 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
41 votes for this article.
Popularity: 7.43 Rating: 4.61 out of 5

1
1 vote, 2.4%
2
3 votes, 7.3%
3
4 votes, 9.8%
4
33 votes, 80.5%
5
Screenshot - palantir.jpg

Screenshot - palantir3.jpg

Introduction

Palantir is an application that allows users to manage remote desktop connections in one window. It also allows users to save existing connections for later use.

Background

The remote desktop connections are managed with Microsoft RDP Client control. This control has all of the properties such as Server, UserName, Domain, etc. in order to set up a remote desktop connection. In addition to these properties, sharing printers, disk drives or color depth of the remote desktop can be managed via RDP Client control. Palantir enables users to create a remote desktop connection and save connection settings for later use. Users can also choose to start a remote desktop connection automatically when the application starts.

The settings can be saved into a file and restored from a setting file. Users can also connect to a computer via console. The application has a class named Machine that stores a remote desktop connection's properties. All of the remote connections created by user is stored in application's .settings file. This setting file has a property setting named MyMachine and its type is string. This property is converted into Hashtable while getting the settings. Palantir's solution consists of four projects which are GUI, Helper, BusinessObjects and a setup project.

Using the Code

The remote desktop connections are retrieved by the function below:

public List<Machine> GetRemoteDesktops()         
{             
    List<Machine> lstMachine = new List<Machine>();             
    if (Settings.Default.MyMachine != "")             
    {                 
        Hashtable ht = 
            (Hashtable)BinarySerializer.BinaryTo(Settings.Default.MyMachine);
        foreach (DictionaryEntry de in ht)                     
        {                     
            Machine insMachine = (Machine)de.Value;                     
            lstMachine.Add(insMachine);                 
        }             
    }               
    lstMachine.Sort(delegate(Machine m1, Machine m2) 
    { 
        return m1.RemoteDesktopConnectionName.CompareTo(
            m2.RemoteDesktopConnectionName); 
    });             
    return lstMachine;         
} 

As seen in the code, this function deserializes the setting named MyMachine into a hashtable and inserts each dictionary entry in the hashtable into a list and returns the list. A remote desktop connection is saved and edited by the function below:

public bool SaveRemoteDesktop(Machine parMachine, bool openedForEdit)   
{             
    if (Settings.Default.MyMachine == "")
    {                 
        Hashtable ht = new Hashtable(); 
        Settings.Default.MyMachine = BinarySerializer.ToBinary(ht); 
        Settings.Default.Save();
    }             
    Hashtable ht1 = 
        (Hashtable)BinarySerializer.BinaryTo(Settings.Default.MyMachine); 
    if (!parMachine.SavePassword) 
    {                 
        parMachine.Password = "";             
    }               
    if (!openedForEdit)             
    {                 
        foreach (DictionaryEntry de in ht1)                 
        {                     
            if (((Machine)de.Value).RemoteDesktopConnectionName == 
                parMachine.RemoteDesktopConnectionName)                     
            {                         
                MessageBox.Show("There is already a 
                                    remote connection with the same name.");                         
                return false;                     
            }                 
        }             
    }               
    ht1[parMachine.RemoteDesktopConnectionName] = parMachine; 
    Settings.Default.MyMachine = BinarySerializer.ToBinary(ht1);
    Settings.Default.Save(); 
    return true; 
}

If there's no currently saved remote desktop connection, we create a new hashtable and then serialize and save the settings file. After that, we deserialize the settings parameter into a hashtable and after checking if there's another connection with the same name, we save the remote desktop connection with the function's parameter Machine object. The methods below set the RDP Client control's settings and connect to the remote desktop which is passed as parameter.

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();         
} 

Feedback

For bug reports and suggestions, feel free to contact me at io1981@hotmail.com.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Isil Orhanel


Member

Occupation: Web Developer
Location: Turkey Turkey

Other popular C# articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 52 (Total in Forum: 52) (Refresh)FirstPrevNext
Generalbeautiful! Pinmemberkanbang0:03 12 Aug '09  
Generalcan u please tell now i am getting this error after change AxMsRdpClient5 to AxMsRdpClient2 Pinmemberravileeladhar8:42 20 Jul '09  
GeneralException ::Error 8 'AxMSTSCLib.AxMsRdpClient4.AdvancedSettings5' is not supported by the language Palantir Pinmemberravileeladhar8:40 9 Jul '09  
GeneralRe: Exception ::Error 8 'AxMSTSCLib.AxMsRdpClient4.AdvancedSettings5' is not supported by the language Palantir PinmemberAKGhosh21:25 19 Jul '09  
GeneralNice Article PinmemberVuyiswa Maseko22:14 4 Mar '09  
GeneralNeed your help! Error:Class not registered... PinmemberMember 388611715:50 15 Feb '09  
GeneralError with mstscax.dll PinmemberMember 393854818:33 15 Jan '09  
Generalerror!!!!. what pas? PinmemberAlejandroDG20:42 17 Oct '08  
Generalplease clear my doubt... [modified] Pinmembersgsiva0:44 18 Sep '08  
AnswerRe: please clear my doubt... PinmemberJim Weiler19:33 19 Nov '08  
GeneralRe: please clear my doubt... PinmemberKevin James23:20 10 Feb '09  
Generalpocket pc version? PinmemberJeff Dafing9:10 17 Aug '08  
GeneralFor windows 2000 Professional Pinmemberkathirvelmm3:21 13 Aug '08  
Generalcan you convert it to vc++ version 6.0 ? PinmemberK.O.1:51 13 Aug '08  
QuestionBuild errors with VS 2005 Pinmembercuriousharry16:16 22 Sep '07  
AnswerRe: Build errors with VS 2005 PinmemberGrantS23:40 23 Oct '07  
GeneralGreat.. PinmemberMurat Firat8:11 12 Sep '07  
QuestionQuery PinmemberRajendrakumara21:15 24 Aug '07  
GeneralWorked at office, error at home Pinmemberzafer_arsay23:30 13 Aug '07  
GeneralWhat is in this name? PinmemberSAKryukov13:02 9 Aug '07  
GeneralRe: What is in this name? PinmemberSacha Barber21:48 9 Aug '07  
GeneralAlready better than MS RDP client, yet needs improvements [modified] PinmemberSAKryukov13:00 9 Aug '07  
GeneralSome fix... [modified] Pinmembercacalex4:07 8 Aug '07  
Generalcool improvement... Pinmembercacalex7:26 7 Aug '07  
NewsClipboard support PinmemberVance Kessler6:24 7 Aug '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 6 Aug 2007
Editor: Deeksha Shenoy
Copyright 2007 by Isil Orhanel
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project