0

我正在尝试获取 RDP 客户端的 IP 地址,以便我们可以记录连接到我们服务器的每个人以及连接到我们服务器的时间。有没有办法使用 VB.net 做到这一点?我尝试过的一切都只返回服务器的 IP 地址。

谢谢!

4

1 回答 1

0

您正在寻找的实际代码的摘录。

 Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim serverName As String
        Dim clientInfo As New WTS_CLIENT_INFO
        ReDim clientInfo.Address(20)
        serverName = ""
        'Server Name can be name of choice or name of server on which this application is running
        If GetSessions(serverName, clientInfo) = True Then
            Dim str As String
            str = "User Name: " & clientInfo.WTSUserName
            str &= vbNewLine & "Station Name: " & clientInfo.WTSStationName
            str &= vbNewLine & "Domain Name: " & clientInfo.WTSDomainName
            If clientInfo.WTSStationName <> "Console" Then
                str &= vbNewLine & "Client Name: " & clientInfo.WTSClientName
                str &= vbNewLine & "Client IP: " & clientInfo.Address(2) & "." & clientInfo.Address(3) & "." & clientInfo.Address(4) & "." & clientInfo.Address(5)
            End If
            MessageBox.Show(str)
        End If
    End Sub
于 2013-08-08T09:55:09.227 回答