Click here to Skip to main content
15,883,917 members
Articles / Programming Languages / C#
Article

Palantir - Remote Desktop Manager

Rate me:
Please Sign up or sign in to vote.
4.90/5 (93 votes)
6 Aug 2007CPOL2 min read 489.9K   65.6K   315   107
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.
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:

C#
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:

C#
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.

C#
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)


Written By
Web Developer
Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerRe: Have you seen.... Pin
Isil Orhanel6-Aug-07 23:32
Isil Orhanel6-Aug-07 23:32 
GeneralRe: Have you seen.... Pin
Vishal.Doshi7-Aug-07 5:25
Vishal.Doshi7-Aug-07 5:25 
GeneralRe: Have you seen.... Pin
dherv1-Oct-07 9:17
dherv1-Oct-07 9:17 
GeneralRe: Have you seen.... Pin
Danilo Corallo19-Oct-07 1:19
Danilo Corallo19-Oct-07 1:19 
QuestionAnother exception, do I need TSC 6.0? Pin
NickViz6-Aug-07 21:31
NickViz6-Aug-07 21:31 
AnswerRe: Another exception, do I need TSC 6.0? Pin
Isil Orhanel6-Aug-07 23:14
Isil Orhanel6-Aug-07 23:14 
GeneralRe: Another exception, do I need TSC 6.0? Pin
liangpz_200013-Sep-07 19:38
liangpz_200013-Sep-07 19:38 
AnswerRe: Another exception, do I need TSC 6.0? Pin
Carlos Solorzano6-Mar-08 10:27
Carlos Solorzano6-Mar-08 10:27 
GeneralRe: Another exception, do I need TSC 6.0? Pin
wongyeam31-Jan-09 20:37
wongyeam31-Jan-09 20:37 
Generalidenty Pin
identy6-Aug-07 12:35
identy6-Aug-07 12:35 
Questionhow can I connect to console? Pin
margiex6-Aug-07 3:32
margiex6-Aug-07 3:32 
AnswerRe: how can I connect to console? Pin
Isil Orhanel6-Aug-07 22:22
Isil Orhanel6-Aug-07 22:22 
QuestionHow to use it? Pin
BarCode2-Aug-07 23:00
BarCode2-Aug-07 23:00 
AnswerRe: How to use it? Pin
Isil Orhanel6-Aug-07 22:40
Isil Orhanel6-Aug-07 22:40 
GeneralWonderful! Pin
Eylon Yogev.2-Aug-07 9:10
Eylon Yogev.2-Aug-07 9:10 
GeneralSuperb Pin
rippo2-Aug-07 7:58
rippo2-Aug-07 7:58 
GeneralGood work... Pin
fadee2-Aug-07 6:07
fadee2-Aug-07 6:07 
GeneralNice article - Superb title! Pin
Iain Clarke, Warrior Programmer2-Aug-07 4:17
Iain Clarke, Warrior Programmer2-Aug-07 4:17 
Generalvery good Pin
Luiz_Augusto2-Aug-07 3:15
Luiz_Augusto2-Aug-07 3:15 
GeneralException Pin
E.Glashagen2-Aug-07 0:28
E.Glashagen2-Aug-07 0:28 
GeneralRe: Exception Pin
sephus62-Aug-07 4:53
sephus62-Aug-07 4:53 
AnswerRe: Exception Pin
Isil Orhanel6-Aug-07 23:37
Isil Orhanel6-Aug-07 23:37 
GeneralRe: Exception Pin
Sönke Cordts14-Aug-07 3:55
Sönke Cordts14-Aug-07 3:55 
Generalgood article Pin
margiex1-Aug-07 23:59
margiex1-Aug-07 23:59 
GeneralExcellent Work Pin
Tamer Oz1-Aug-07 21:19
Tamer Oz1-Aug-07 21:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.