如何在WPF中获取Windows用户名

前端之家收集整理的这篇文章主要介绍了如何在WPF中获取Windows用户名前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在我的WPF应用程序中显示用户名,应该从当前登录用户那里获取用户名

所以我的问题如何从WPF应用程序获取登录用户的Windows用户名

System.Security.Principal.WindowsIdentity.GetCurrent().Name

我也发现:

Environment.UserName

要么

System.Windows.Forms.SystemInformation.UserName

我不能尝试,所以检查自己的结果。

添加
完整用户名

Imports System.DirectoryServices.AccountManagement

Dim userFullName As String = UserPrincipal.Current.DisplayName
原文链接:https://www.f2er.com/windows/372426.html

猜你在找的Windows相关文章