Click here to Skip to main content
15,888,579 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 490.9K   65.7K   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: Build errors with VS 2005 Pin
GrantS23-Oct-07 22:40
GrantS23-Oct-07 22:40 
GeneralGreat.. Pin
Murat Firat12-Sep-07 7:11
Murat Firat12-Sep-07 7:11 
QuestionQuery Pin
Rajendrakumara24-Aug-07 20:15
Rajendrakumara24-Aug-07 20:15 
GeneralWorked at office, error at home Pin
zafer_arsay13-Aug-07 22:30
zafer_arsay13-Aug-07 22:30 
QuestionWhat is in this name? Pin
Sergey Alexandrovich Kryukov9-Aug-07 12:02
mvaSergey Alexandrovich Kryukov9-Aug-07 12:02 
AnswerRe: What is in this name? Pin
Sacha Barber9-Aug-07 20:48
Sacha Barber9-Aug-07 20:48 
AnswerRe: What is in this name? Pin
pauljenkins71425-Mar-10 22:20
pauljenkins71425-Mar-10 22:20 
GeneralAlready better than MS RDP client, yet needs improvements [modified] PinPopular
Sergey Alexandrovich Kryukov9-Aug-07 12:00
mvaSergey Alexandrovich Kryukov9-Aug-07 12:00 
Great work, really. One biggest practical problem working with MS RDP client is mismatch between screen pixel sizes in client and server machine, especially with different aspect ratio. It looks like you've resolved it in an optimal way -- your client works with the screen as it is on the client system.

Now, let me list the improvements I would suggest:

1) Run-time:
1.1) It needs full-screen mode much like the one in MS RDP client. It would be especially helpful to avoid confusion between server's and client's "Start" button and other confusing Ui elements.
Note, that in the full-screen mode the client ignores your local system's key strokes like Ctrl+Esc and emulate those on server side. Again, MS RDP client handles full-screen only for matching screen resolutions, but I am sure you can do much better and provide full-screen mode in all cases. Seriously, this is a key usability issue.
1.2) Your session data file extension (*.pln) should be usable by Palantir in a command line to establish connection from this file. In this way, Palantir could be launched from batch, *.lnk files, via Shell (when file extension is registered to be opened with Palantir), etc. Also, the user may want to use singleton (single-instance of the client) style of using the application.
1.3) You could work with standard MS *.rdp files. The user can be allowed to re-register this file extension with the Shell to use Palantir -- optionally and removable via setup (uninstall).
1.4) Leaving whole menu without hot keys (I mean, "&"-prefixed letter to be used with Alt+) is not nice.
1.5) "Export settings to file" raises exception when I used some longer password; I don't know why. As I understand now, this is some password that has nothing to do with remote password, but this is not clear from your Ui.

2) Build:
2.1) Your source code is linked with with some inaccessible version control database. You had better to clean it before publishing. (Also, is it MS SourceSafe? Well, who use SourceSafe? Use SVN! And who need Visual Studio integration?... Anyway, this has nothing to do with your project; just please detach version control for convenience of other readers...)
2.2) AxMSTSCLib.AxMsRdpClient4 did not work for me. I had to change it to
AxMSTSCLib.AxMsRdpClient2 everywhere. Maybe, not everyone has required versions of the library. After this modification, I managed to build it all.
2.3) At first, as I always do, I removed all bin directories before build. The build failed because Palantir.ico was not found. This indicates that something is wrong in the structure of your project (I did not figure out exactly). Well-design project provides strict isolation between source code and targets; it always builds on pure source without binaries. You code does, too, one when one removes Palantir.ico form the project and adds again in a right way.

I really think these improvements are minor yet critical for usability. If you be so nice to do it, everyone would be just happy.
Thank you for this work very much!
--Sergey




-- modified at 18:20 Thursday 9th August, 2007

Sergey A Kryukov

GeneralSome fix... [modified] Pin
cacalex8-Aug-07 3:07
cacalex8-Aug-07 3:07 
Generalcool improvement... Pin
cacalex7-Aug-07 6:26
cacalex7-Aug-07 6:26 
NewsClipboard support Pin
Vance Kessler7-Aug-07 5:24
Vance Kessler7-Aug-07 5:24 
GeneralGood job and ... good name Pin
Crusty Applesniffer7-Aug-07 0:22
Crusty Applesniffer7-Aug-07 0:22 
GeneralHave you seen.... Pin
Peter Tewkesbury6-Aug-07 23:01
professionalPeter Tewkesbury6-Aug-07 23:01 
AnswerRe: Have you seen.... PinPopular
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.... PinPopular
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 

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.