标签:
取得操作系统用户名称:
public async static Task<string> GetDisplayNameAsync() { string displayName = await UserInformation.GetDisplayNameAsync(); if (string.IsNullOrEmpty(displayName)) displayName = DefaultDisplayName; return displayName; }
取得当前机器名称:
public static string GetMachineName() { IReadOnlyList<HostName> hostNames = NetworkInformation.GetHostNames(); HostName hostName = hostNames.FirstOrDefault(x => x.Type == HostNameType.DomainName); if (hostName == null) return DefaultMachineName; return hostName.DisplayName; }
标签:
原文地址:http://www.cnblogs.com/bent/p/4546957.html