[英]Getting the name of the current user (not the username)
我已经阅读了一些有关获取当前用户名称的帖子,这些帖子使用以下两种方法之一:
Environment.UserName;
System.Security.Principal.WindowsIdentity.GetCurrent().Name
这将获取当前已登录用户的用户名,但是我想知道如何获取已登录用户的名称? (因此不是登录名,而是锁定计算机时也会保存并显示的名称)
using System.DirectoryServices.AccountManagement;
UserPrincipal userPrincipal = UserPrincipal.Current;
String name = userPrincipal.DisplayName;
该代码对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.