首页 > 代码库 > c?#? ?利?用?m?s?t?s?c? ?协?议?实?现?固?定?窗?口?的?远?程?桌?面

c?#? ?利?用?m?s?t?s?c? ?协?议?实?现?固?定?窗?口?的?远?程?桌?面

  1 using System;  2 using System.Collections.Generic;  3 using System.ComponentModel;  4 using System.Data;  5 using System.Drawing;  6 using System.Text;  7 using System.Windows.Forms;  8 using System.IO;  9 using System.Xml; 10  11 namespace RDP_From 12 { 13     public partial class Form1 : Form 14     { 15         /// <summary> 16         ///  17         /// </summary> 18         private bool bQuitAck = false; 19         private Point P_Location = new Point(0, 0); 20         private Size F_Size = new Size(1200, 1024); 21         private string C_Name = ""; 22          23         /// <summary> 24         ///  25         /// </summary> 26         public Form1() 27         { 28             InitializeComponent(); 29             this.panel1.Visible = false; 30             if (ReadSettions()) 31             { 32                 this.Location = P_Location; 33                 this.Size = F_Size; 34                 this.FormBorderStyle = FormBorderStyle.None; 35             } 36             else 37             { 38                 this.Size = Screen .PrimaryScreen .WorkingArea .Size ; 39             } 40             this.rdp_Client.Size = this.Size; 41             rdp_Client.Server = System.Configuration.ConfigurationManager.AppSettings["C_SERVER"].ToString(); 42             rdp_Client.UserName = System.Configuration.ConfigurationManager.AppSettings["C_USER_NA"].ToString(); 43             rdp_Client.Domain = System.Configuration.ConfigurationManager.AppSettings["C_DOMAIN"].ToString(); 44             rdp_Client.AdvancedSettings2.ClearTextPassword = System.Configuration.ConfigurationManager.AppSettings["C_PSW"].ToString(); 45              46             rdp_Client.Connect(); 47         } 48  49         private bool ReadSettions() 50         { 51             try 52             { 53                 string filename = Application.StartupPath + "\\SpecialSettings.XML"; 54                 XmlDocument xd = new XmlDocument(); 55                 xd.Load(filename); 56  57                 XmlNode xns = xd.SelectSingleNode("/Settings"); 58  59  60                 P_Location.X =Convert .ToInt32( xns["X"].InnerText); 61                 P_Location.Y =Convert .ToInt32 ( xns["Y"].InnerText); 62                 F_Size.Width =Convert .ToInt32 ( xns["Width"].InnerText); 63                 F_Size.Height =Convert .ToInt32 ( xns["Height"].InnerText); 64                 C_Name = xns["Name"].InnerText; 65                 return true; 66             } 67             catch(Exception e) 68             { 69                 return false; 70             } 71  72         } 73  74         private void Form1_FormClosing(object sender, FormClosingEventArgs e) 75         { 76             this.panel1.Visible = true; 77             if( bQuitAck ==false ) 78                 e.Cancel = true; 79         } 80  81         private void but_Yes_Click(object sender, EventArgs e) 82         { 83             bQuitAck = true ; 84             this.Close(); 85         } 86  87         private void but_Cancel_Click(object sender, EventArgs e) 88         { 89             bQuitAck = false; 90             this.panel1.Visible = false; 91             this.rdp_Client .Focus(); 92         } 93  94         95  96         private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e) 97         { 98             this.Close(); 99         }100 101         private void 重新连接ToolStripMenuItem_Click(object sender, EventArgs e)102         {103             if (rdp_Client.Connected == 1) return;104             rdp_Client.Connect();105         }106 107         private void Form1_Resize(object sender, EventArgs e)108         {109         }110 111         112     }113 }

 

c?#? ?利?用?m?s?t?s?c? ?协?议?实?现?固?定?窗?口?的?远?程?桌?面