public static string GetCurrentUser()
{
string name = Environment.UserName;
string fullname="";
ManagementClass account = new ManagementClass("Win32_UserAccount");
ManagementObjectCollection acc = account.GetInstances();
foreach (ManagementObject obj in acc)
{
if (obj.Properties["Name"].Value.ToString() == name)
{
fullname = obj.Properties["FullName"].Value.ToString();
}
}
return fullname;
}
.Net 实时获取Window 用户名称
最新推荐文章于 2022-06-21 09:59:00 发布