5,445,109 members and growing! (14,911 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, C#Windows, .NET, .NET 2.0, Win2K, WinXP, Win2003, VistaVS2005, Visual Studio, Architect, DBA, Dev

Posted: 1 Aug 2007
Updated: 6 Aug 2007
Views: 37,997
Bookmarked: 96 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
31 votes for this Article.
Popularity: 6.74 Rating: 4.52 out of 5
0 votes, 0.0%
1
1 vote, 3.2%
2
3 votes, 9.7%
3
4 votes, 12.9%
4
23 votes, 74.2%
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



Occupation: Web Developer
Location: Turkey Turkey

Other popular C# articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 40 (Total in Forum: 40) (Refresh)FirstPrevNext
Subject  Author Date 
Generalpocket pc version?memberJeff Dafing9:10 17 Aug '08  
GeneralFor windows 2000 Professionalmemberkathirvelmm3:21 13 Aug '08  
Generalcan you convert it to vc++ version 6.0 ?memberK.O.1:51 13 Aug '08  
QuestionBuild errors with VS 2005membercuriousharry16:16 22 Sep '07  
AnswerRe: Build errors with VS 2005memberGrantS23:40 23 Oct '07  
GeneralGreat..memberMurat Firat8:11 12 Sep '07  
QuestionQuerymemberRajendrakumara21:15 24 Aug '07  
GeneralWorked at office, error at homememberzafer_arsay23:30 13 Aug '07  
GeneralWhat is in this name?memberSAKryukov13:02 9 Aug '07  
GeneralRe: What is in this name?memberSacha Barber21:48 9 Aug '07  
GeneralAlready better than MS RDP client, yet needs improvements [modified]memberSAKryukov13:00 9 Aug '07  
GeneralSome fix... [modified]membercacalex4:07 8 Aug '07  
Generalcool improvement...membercacalex7:26 7 Aug '07  
NewsClipboard supportmemberVance Kessler6:24 7 Aug '07  
GeneralGood job and ... good namememberCrusty Applesniffer1:22 7 Aug '07  
GeneralHave you seen....memberPeter Tewkesbury0:01 7 Aug '07  
AnswerRe: Have you seen....memberIsil Orhanel0:32 7 Aug '07  
GeneralRe: Have you seen....memberVishal.Doshi6:25 7 Aug '07  
GeneralRe: Have you seen....memberdherv10:17 1 Oct '07  
GeneralRe: Have you seen....memberDanilo Corallo2:19 19 Oct '07  
GeneralAnother exception, do I need TSC 6.0?memberNickViz22:31 6 Aug '07  
AnswerRe: Another exception, do I need TSC 6.0?memberIsil Orhanel0:14 7 Aug '07  
GeneralRe: Another exception, do I need TSC 6.0?memberliangpz_200020:38 13 Sep '07  
GeneralRe: Another exception, do I need TSC 6.0?memberCarlos Solorzano11:27 6 Mar '08  
Generalidentymemberidenty13:35 6 Aug '07