如何在 WPF 中获取 Windows 用户名 [英] how to Get Windows Username in WPF
本文介绍了如何在 WPF 中获取 Windows 用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的 WPF 应用程序中显示用户名,它应该从当前登录的用户那里获取用户名?
I would like to display the Username in my WPF application, where it should get the username from the current user logged in?
所以我的问题是如何从 WPF 应用程序获取 Windows 登录用户的用户名?
so my question how can we get the username of windows logged in user from WPF App ?
推荐答案
System.Security.Principal.WindowsIdentity.GetCurrent().Name
我还发现:
Environment.UserName
或
System.Windows.Forms.SystemInformation.UserName
我无法尝试,请自行检查结果.
I cannot try it so check for yourself the result.
补充:完整用户名:
Imports System.DirectoryServices.AccountManagement
Dim userFullName As String = UserPrincipal.Current.DisplayName
这篇关于如何在 WPF 中获取 Windows 用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文