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;
        }

 

posted @ 2015-06-02 16:51  咆哮  阅读(152)  评论(0编辑  收藏  举报