RDP Terminal Service API

  • Thread starter Thread starter whitethomas12
  • Start date Start date
W

whitethomas12

Ok, I can get terminal services to work in VbScript, but when I add
reference to the Mstscax.dll
and add the following code, I get a blank screen (I am using ASP.NET
2.0 VB):

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim RDP As MSTSCLib.IMsRdpClient2 = New
MSTSCLib.MsRdpClient2()


RDP.Server = "192.168.4.2"
RDP.UserName = "xxxx"
RDP.FullScreen = True
RDP.DesktopHeight = 300
RDP.DesktopWidth = 300
RDP.Connect()
End Sub


After research on the web I found that I have to create new AxMSTSCLib
and MSTSCLib DLLs. So I did and I cannot for the life of me be able
to get this to work


I am not sure what I am doing wrong. Can someone please help me on
this.
 
Ok, I can get terminal services to work in VbScript, but when I add
reference to the Mstscax.dll
 and add the following code, I get a blank screen (I am using ASP.NET
2.0 VB):

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
        Dim RDP As MSTSCLib.IMsRdpClient2 = New
MSTSCLib.MsRdpClient2()

        RDP.Server = "192.168.4.2"
        RDP.UserName = "xxxx"
        RDP.FullScreen = True
        RDP.DesktopHeight = 300
        RDP.DesktopWidth = 300
        RDP.Connect()
    End Sub

After research on the web I found that I have to create new AxMSTSCLib
and  MSTSCLib DLLs.  So I did and I cannot for the life of me be able
to get this to work

I am not sure what I am doing wrong. Can someone please help me on
this.

have been still trying to fiddle around with this and cannot figure
out what i am foinf wrong. Will someone please review my code and
help me



This is my new code. Please note that I have been trying it multiple
ways and some things are remarked out:



Friend WithEvents AxMsRdpClient21 As AxMSTSCLib.AxMsRdpClient2

Friend WithEvents TCS As IMsRdpClient2

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

Me.TCS = New MsRdpClient2

' Me.AxMsRdpClient21 = New AxMSTSCLib.AxMsRdpClient2

'CType(Me.AxMsRdpClient21,
System.ComponentModel.ISupportInitialize).BeginInit()

CType(Me.TCS, System.ComponentModel.ISupportInitialize).BeginInit()

' ' Me.SuspendLayout()

' 'AxMsRdpClient21

''

'Me.AxMsRdpClient21.Location = New System.Drawing.Point(58, 17)

Me.TCS.Location = New System.Drawing.Point(58, 17)

'Me.AxMsRdpClient21.Dock = System.Windows.Forms.DockStyle.Top

Me.TCS.Dock = System.Windows.Forms.DockStyle.Top

' Me.AxMsRdpClient21.Enabled = True

Me.TCS.Enabled = True

' Me.AxMsRdpClient21.Name = "AxMsRdpClient21"

Me.TCS.Name = "TCS"

' Me.AxMsRdpClient21.OcxState =
CType(GetObject("AxMsRdpClient21.OcxState"),
System.Windows.Forms.AxHost.State)

Me.TCS.OcxState = CType(GetObject("TCS.OcxState"),
System.Windows.Forms.AxHost.State)

'Me.AxMsRdpClient21.Size = New System.Drawing.Size(100, 100)

Me.TCS.Size = New System.Drawing.Size(100, 100)

'Me.AxMsRdpClient21.TabIndex = 1

Me.TCS.TabIndex = 0



'CType(Me.AxMsRdpClient21,
System.ComponentModel.ISupportInitialize).EndInit()

CType(Me.TCS, System.ComponentModel.ISupportInitialize).EndInit()

Me.Controls.Add(Me.TCS)

TCS.Server = "192.168.4.2"

TCS.Connect()



'Me.ResumeLayout(False)

'Me.AxMsRdpClient21.Server = "192.168.4.2"

'Me.AxMsRdpClient21.Connect()

End Sub
 
I am using VB2008

I am using VB2008 and what I did was create the following code take a look
Code:
[size=2][color=#0000ff][size=2][color=#0000ff]Imports[/color][/size][/color][/size][size=2] System.Drawing
[/size][size=2][color=#0000ff][size=2][color=#0000ff]Imports[/color][/size][/color][/size][size=2] System.Windows.Forms[/size]
[size=2][size=2][color=#0000ff][size=2][color=#0000ff]Public[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]Class[/color][/size][/color][/size][size=2] Form1 
[color=seagreen]'this should work if you are using the latest version of mstsc[/color]
[/size][size=2] 
 
[/size][size=2][color=#0000ff][size=2][color=#0000ff]Private[/color][/size][/color][/size][size=2] rdpControl = [/size][size=2][color=#0000ff][size=2][color=#0000ff]New[/color][/size][/color][/size][size=2] AxMSTSCLib.AxMsRdpClient7NotSafeForScripting()[/size]
 
public sub activate_rdp ()
[color=seagreen]'this will loop untill status changes and allows to connect[/color] 
[size=2][size=2][size=2]ftl:
[/size][/size][size=2][color=#0000ff][size=2][color=#0000ff]Try
[/color][/size][/color][/size][/size][size=2][size=2][size=2]rdpControl .Height = 870
 
rdpControl .Width = 1000
 
rdpControl .Server = "10.10.0.1"
[/size][size=2]rdpControl .Connect()[/size]
[size=2][size=2][color=#0000ff][size=2][color=#0000ff]Catch[/color][/size][/color][/size][size=2] cx [/size][size=2][color=#0000ff][size=2][color=#0000ff]As[/color][/size][/color][/size][size=2] AxHost.InvalidActiveXStateException
[/size][size=2][color=#0000ff][size=2][color=#0000ff]GoTo[/color][/size][/color][/size][size=2] ftl
[/size][size=2][color=#0000ff][size=2][color=#0000ff]End[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]Try[/color][/size][/color][/size]

[size=2][color=#0000ff][size=2][color=#0000ff]End Sub
[/color][/size][/color][/size][/size][/size][/size][/size]

Then call the sub from the a button click like this
Code:
 activate_rdp ()

ok hope that helps
 
Back
Top