Imports MSTSCLib
Public Class Form1
Private Sub ConnectToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectToolStripMenuItem.Click
If rdp.Connected.ToString() = "0" Then
Try
rdp.Server = txtServer.Text 'Indirizzo IP o Nome del Computer da collegargi
rdp.Domain = txtDominio.Text 'Dominio di Rete del Computer Remoto
rdp.UserName = txtUsername.Text 'Nome Utente, se non si mette niente appare la richiesta di collegamento
Dim secured As IMsTscNonScriptable = DirectCast(rdp.GetOcx(), IMsTscNonScriptable)
secured.ClearTextPassword = txtPassword.Text 'Password Utente
rdp.Connect()
Catch ex As Exception
MessageBox.Show(ex.Message, Me.Name, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
Private Sub DisconnectToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisconnectToolStripMenuItem.Click
If rdp.Connected.ToString() = "1" Then
rdp.Disconnect()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MaximizeBox = True 'Per far apparire a tutto schermo il programma
txtPassword.TextBox.PasswordChar = "*"c 'Per rendere la Password non leggibile
End Sub
End Class