Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More on RDP and VB.Net

Status
Not open for further replies.

dean12

MIS
Oct 23, 2001
273
0
0
US
I'm in VS 2008 VB.NET

I have a form with the RDP control on the form. In the Form1_Load event I set the parameters to connect:

rdp6.Server = "10.1.1.1"
rdp6.UserName = "abc"
rdp6.AdvancedSettings2.ClearTextPassword = "def"
rdp6.Connect()

It connects and I see the remote system. Now on the remote I logoff. Fine.

What I would like to do is detect the disconnect and close down the executing program. So I use one of the RDP events:


Private Sub rdp6_OnDisconnected(ByVal sender As Object, ByVal e As AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEvent) Handles rdp6.OnDisconnected
Me.Close()
End Sub


It appears to want to do the job but I get an error:

AccessViolationException was unhandled

Attempt to read or write protected memory. This is often an indicate that other memory is corrupt.


OK, sure. I got no idea.


 
Is the program you are trying to close running on the client or the server? I'd guess it's on the server, and TBH you shouldn't really be auto-closing OnDisconnected (it's too late anyway) - it might be just a network glitch, not a "proper" Close.

Likewise, if you're doing that on the client, every time someone reboots a router your program's going to boot you out to the desktop without warning - still not good.

And BTW Me.Close will close the active form but not necerrily the entire program.

I used to be the Comaboy on Tek-Tips.

...And the despicable Jeremy Vyle elsewhere. ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top