【发布时间】:2014-09-16 05:18:38
【问题描述】:
我正在开发一个供个人使用的终端服务应用程序,它允许我通过选项卡列出和管理我的所有 RDP 会话(我知道这些会话存在,但也将其用作一个小型学习项目)。我想知道是否有人可以帮助处理一些项目。我正在尝试动态创建选项卡和 RDP 控件并将其添加到每个选项卡上。对于创建第一个标签页和控件,这似乎可以正常工作,但在随后的标签页和控件中失败,并出现以下代码错误:
Dim theNewTabPage As New DevExpress.XtraTab.XtraTabPage()
theNewTabPage.Text = txtserver.Text
theNewTabPage.Name = Minute(DateTime.Now) & Second(DateTime.Now)
Dim RDPCONTROL As New AxMSTSCLib.AxMsRdpClient9NotSafeForScripting
RDPCONTROL.Dock = DockStyle.Fill
'Just a test to ensure unique name
RDPCONTROL.Name = Minute(DateTime.Now) & Second(DateTime.Now)
XtraTabControl1.TabPages.Add(theNewTabPage)
theNewTabPage.Controls.Add(RDPCONTROL)
Try
RDPCONTROL.Server = txtserver.Text
RDPCONTROL.Domain = txtdomain.text
RDPCONTROL.UserName = txtusername.Text
Dim secured As MSTSCLib.IMsTscNonScriptable = DirectCast(RDPCONTROL.GetOcx(), MSTSCLib.IMsTscNonScriptable)
secured.ClearTextPassword = txtpassword.Text
RDPCONTROL.Connect()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try`
创建第二个连接时出错:
Using ex.message: exception of type 'system.windows.forms.axhost+invalidactivexstateexception was thrown
Using ex.tostring: property set of 'Server' cannot be invoked at this time
下一项是如何检测 RDP 会话是否在选项卡上断开连接,然后弹出一条消息并关闭所需的选项卡
【问题讨论】: