编辑
我仍然无法为进程分配与之关联的会话 ID 的用户名。
这是我用来检索用户详细信息的代码:
Public Sub GetUsers()
Using server As ITerminalServer = manager.GetRemoteServer(strHostName)
server.Open()
For Each session As ITerminalServicesSession In server.GetSessions()
If Not String.IsNullOrEmpty(session.UserName) Then
dictuser.Add(session.SessionId, New User(session.SessionId, session.UserName))
End If
Next
End Using
End Sub
我的用户类简单定义为:
Public Class User
Private _SessionID As Integer
Private _UserName As String
Sub New(ByVal SessionID As Integer, ByVal UserName As String)
_SessionID = SessionID
_UserName = UserName
End Sub
Public ReadOnly Property SessionID As String
Get
Return _SessionID
End Get
End Property
Public ReadOnly Property UserName As String
Get
Return _UserName
End Get
End Property
End Class
我在我的流程类中创建了一个函数:
Public Sub AddUserInfo(ByVal UserName As String)
_UserName = UserName
End Sub