window7 remote desktop functionality using Microsoft com component mstscax.dll

  • 2020-05-27 06:58:19
  • OfStack


namespace Client
{
    public partial class Login : Form
    {
        private string ip = null;
        public Login()
        {
            InitializeComponent();
        }
        public Login(string IP)
        {
            InitializeComponent();
            ip = IP;
        }
        private void Login_Load(object sender, EventArgs e)
        {
            this.FormClosing += Login_Closing;
            this.Text = string.Format(" Log in to: {0}", ip);
            //  Gets the host monitor screen resolution 
            Rectangle rect = Screen.PrimaryScreen.Bounds;
            try
            {
                rdp.Server = ip;
                rdp.AdvancedSettings2.RDPPort = 3389;
                rdp.Height = rect.Height;
                rdp.Width = rect.Width;
                //rdp.UserName = "client";
                //rdp.AdvancedSettings2.ClearTextPassword = "client";
                rdp.Connect();
                rdp.FullScreen = true;
                //this.FormBorderStyle = FormBorderStyle.None;
                rdp.FullScreenTitle = this.Text;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Login_Closing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show(" Confirm exit? ", " prompt ", MessageBoxButtons.YesNo, 
                MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                e.Cancel = true;
        }
    }
}


Related articles: