Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- rdp.Server = txtServer.Text;
- rdp.UserName = txtUserName.Text;
- IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
- secured.ClearTextPassword = txtPassword.Text;
- rdp.Connect();
- }
- catch (Exception Ex)
- {
- MessageBox.Show("Error connecting to remote desktop " + txtServer.Text + " Error: " + Ex.Message,"Error Connecting",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 " + txtServer.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement