Advertisement
Guest User

Untitled

a guest
May 24th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. try
  4. {
  5. rdp.Server = txtServer.Text;
  6. rdp.UserName = txtUserName.Text;
  7. IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
  8. secured.ClearTextPassword = txtPassword.Text;
  9. rdp.Connect();
  10. }
  11. catch (Exception Ex)
  12. {
  13. MessageBox.Show("Error connecting to remote desktop " + txtServer.Text + " Error: " + Ex.Message,"Error Connecting",MessageBoxButtons.OK, MessageBoxIcon.Error);
  14. }
  15. }
  16.  
  17. private void button2_Click(object sender, EventArgs e)
  18. {
  19. try
  20. {
  21. // Check if connected before disconnecting
  22. if (rdp.Connected.ToString() == "1")
  23. rdp.Disconnect();
  24. }
  25. catch (Exception Ex)
  26. {
  27. //MessageBox.Show("Error Disconnecting", "Error disconnecting from remote desktop " + txtServer.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement