我如何获取已登录用户的显示名称?不是用户名,而是显示名称,例如下面的屏幕截图中所示 - 以及在任何Windows Vista / 7计算机的开始菜单中看到的内容。
Imports System.Security.Principal
Imports System.Threading
Imports System.IO
Imports System
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox("1: " & System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString & vbCrLf & _
"2: " & Environment.UserDomainName & vbCrLf & _
"3: " & WindowsIdentity.GetCurrent().Name & vbCrLf & _
"4: " & Thread.CurrentPrincipal.Identity.Name & vbCrLf & _
"5: " & Environment.UserName & vbCrLf & _
"6: " & My.User.Name & vbCrLf &
"7: " & My.Computer.Name)
End Sub
End Class