随笔-137  评论-39  文章-1  trackbacks-0

Palantir - Remote Desktop Manager

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 it's 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.

Collapse
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();
}
posted on 2007-08-14 14:12 心悦 阅读(3675) 评论(2) 编辑 收藏

评论:
#1楼 2008-11-17 10:21 | 米虫      
你好,最近想用c#做一个远程桌面控制的软件。

发现网上的资料很少,请问你又没实现的代码供参考下呢?

或者请求给个设计的思路吧。

thanks very much!

我的邮箱:zhangkai0309@163.com

谢谢!@

 回复 引用 查看   
#2楼 2009-07-21 17:30 | 火龙      
我也想要啊,jksharp@163.com
 回复 引用 查看   
年轻人要想做成一点事情,资金不是最重要,重要的是要敢想、敢冒险,善于学习、善于从实践中获得经验。年轻人最大的资本就是可以毫无顾虑地做很多事情,这是一种积淀,所以说,趁年轻时多学习点东西,多尝试些有用的工作,绝对不是坏事。
昵称:心悦
园龄:6年4个月
粉丝:7
关注:4
<2007年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

搜索

 

常用链接

最新随笔

我的标签

随笔分类(128)

随笔档案(137)

文章档案(1)

GoodLearning

积分与排名

  • 积分 - 70390
  • 排名 - 1495

最新评论

阅读排行榜

评论排行榜

推荐排行榜