windows8 取得系统信息
取得操作系统用户名称:
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; }