namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void txtPort_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { try { rdp.Server = textBox1.Text; rdp.UserName = textBox2.Text; System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping(); System.Net.NetworkInformation.PingReply pingReply = ping.Send(rdp.Server); if (pingReply.Status == IPStatus.Success) { IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx(); secured.ClearTextPassword = textBox3.Text; rdp.Connect(); } } catch (Exception Ex) { MessageBox.Show("Error Connecting RDC", "Error connecting to remote desktop " + textBox1.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } try { rdp2.Server = textBox1.Text; rdp2.UserName = textBox2.Text; System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping(); System.Net.NetworkInformation.PingReply pingReply = ping.Send(rdp2.Server); if (pingReply.Status == IPStatus.Success) { IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp2.GetOcx(); secured.ClearTextPassword = textBox3.Text; rdp2.Connect(); } } catch (Exception Ex) { MessageBox.Show("Error Connecting RDC", "Error connecting to remote desktop " + textBox1.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void button2_Click(object sender, EventArgs e) { try { // Check if connected before disconnecting if (rdp.Connected.ToString() == "1") rdp.Disconnect(); } catch (Exception Ex) { MessageBox.Show("Error Disconnecting", "Error disconnecting from remote desktop " + textBox1.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)