简体   繁体   English

我们如何从UWP中的Windows 10获取工作组名称?

[英]How do we get workgroup name from windows 10 in uwp?

How do we get workgroup name from windows 10 in uwp 我们如何从UWP中的Windows 10获取工作组名称

and all other attribute of user? 以及用户的所有其他属性?

There is a User class available (UWP): https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.user.aspx 有一个可用的用户类(UWP): https : //msdn.microsoft.com/en-us/library/windows/apps/windows.system.user.aspx

There you can find the attributes of the user 在那里您可以找到用户的属性

You can use NetworkInformation class 您可以使用NetworkInformation

For example to get computer name use: 例如,要获取计算机名称,请使用:

var hostNames = NetworkInformation.GetHostNames();
var localName = hostNames.FirstOrDefault(name => name.DisplayName.Contains(".local"));
var computerName = localName.DisplayName.Replace(".local", "");

Or you can also use ConnectionProfile to get information about network. 或者,您也可以使用ConnectionProfile获取有关网络的信息。
Try something like this: 尝试这样的事情:

var result = NetworkInformation.GetConnectionProfiles();
foreach (var connectionProfile in result)
{
    foreach (var networkName in connectionProfile.GetNetworkNames())
    {
        // use networkName;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM