Jump to content

Terminal service virtual channel problem with VB6


Recommended Posts

Guest junlia
Posted

Hi Everyone,

 

I have implemented sending message via virtual channel to terminal service

server app in C#. However, due to the project requirement, I need to re-write

this in VB6. However I am having issues with

MsRdpClient31.CreateVirtualChannels

and MsRdpClient31.SendOnVirtualChannel methods. I received Method

'CreateVirtualChannels' of object 'MsRdpClient31' failed and

Method 'SendOnVirtualChannel' of object 'MsRdpClient31' failed errors.

 

If I put in 'On Error Resume Next' statement before the the methods calls,

it would skip the first SendOnVirtualChannel call as it would error out, and

create the virtual channel even though generate error, and does the

subsequent SendOnVirtualChannel without any error. One odd thing is

that I can not send the same message immediately after the failed

SendOnVirtualChannel call. Sample code attached below.

 

I did install different versions of rdp web connection controls on my

machine, but only registered one msrdp.ocx. Even after I un-install the RDP

web connection software, the program still run with the same problems as

stated above. Not sure if I am getting into the dll hell situation... I run

the app at a win 2000 machine, still got the errors at these methods calls,

but with different error message " Automation error".

 

Any pointers would be appreciated.

 

Thanks

Junlia

 

PS. attched is the sample code:

 

Private Sub Command1_Click()

 

On Error Resume Next

Set Rdp = MsRdpClient31.Object

MsRdpClient31.Server = Text1.Text

MsRdpClient31.UserName = "user"

MsRdpClient31.DesktopHeight = 600

MsRdpClient31.DesktopWidth = 800

Rdp.ClearTextPassword = "password"

MsRdpClient31.SecuredSettings.WorkDir = "C:\test\"

MsRdpClient31.SecuredSettings.StartProgram = "C:\test\tsserverconsole.exe"

 

If Err.Number <> 0 Then

MsgBox "befor create VC: err " & Err.Number & "; desc: " & Err.Description

Err.Clear

End If

MsRdpClient31.CreateVirtualChannels ("TSCS")

If Err.Number <> 0 Then

MsgBox "create VC: err " & Err.Number & "; desc: " & Err.Description

Err.Clear

End If

 

MsRdpClient31.Connect

‘ wait for connection to establish ot timed out

Dim wait As Date

wait = DateAdd("s", 3, Now)

Do

DoEvents

Loop Until (Now > wait) Or MsRdpClient31.Connected

 

If Not MsRdpClient31.Connected Then

Msgbox "Connection failed (took longer than 3 seconds)."

Exit Sub

end If

 

If Err.Number <> 0 Then

MsgBox "Before send: err " & Err.Number & "; desc: " & Err.Description

Err.Clear

End If

 

MsRdpClient31.SendOnVirtualChannel "TSCS", "SUZUKI"

 

If Err.Number <> 0 Then

MsgBox "send suzuki err " & Err.Number & "; desc: " & Err.Description

Err.Clear

End If

 

'---- if uncomment the next line, the code from here on will not get

executed. ----

'MsRdpClient31.SendOnVirtualChannel "TSCS", "SUZUKI"

MsRdpClient31.SendOnVirtualChannel "TSCS", "FORD"

If Err.Number <> 0 Then

MsgBox "send Ford err " & Err.Number & "; desc: " & Err.Description

 

Err.Clear

End If

 

 

MsRdpClient31.SendOnVirtualChannel "TSCS", "SUZUKI"

If Err.Number <> 0 Then

MsgBox "send suzuki err " & Err.Number & "; desc: " & Err.Description

Err.Clear

End If

End Sub

  • Replies 0
  • Created
  • Last Reply

Popular Days


×
×
  • Create New...