Пример #1
0
        /// <summary>
        /// hdt
        /// </summary>
        /// <returns></returns>
        public static Task <ProcessorArchitecture> GetProcessorArchitectureAsync()
        {
            TaskAwaiter <PnpObject> awaiter = SystemInfoEstimate.GetHalDevice(new string[] { "System.ItemNameDisplay" }).GetAwaiter();
            PnpObject             halDevice = awaiter.GetResult();
            ProcessorArchitecture arm;

            if (halDevice != null && halDevice.Properties["System.ItemNameDisplay"] != null)
            {
                string str = halDevice.Properties["System.ItemNameDisplay"].ToString();
                if (str.Contains("x64"))
                {
                    arm = ProcessorArchitecture.X64;
                }
                else if (str.Contains("ARM"))
                {
                    arm = ProcessorArchitecture.Arm;
                }
                else
                {
                    arm = ProcessorArchitecture.X86;
                }
            }
            else
            {
                arm = ProcessorArchitecture.Unknown;
            }
            return(Task.FromResult <ProcessorArchitecture>(arm));
        }
Пример #2
0
        /// <summary>
        /// hdt
        /// </summary>
        /// <returns></returns>
        public static Task <string> GetWindowsVersionAsync()
        {
            TaskAwaiter <PnpObject> awaiter;

            awaiter = SystemInfoEstimate.GetHalDevice(new string[] { "{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3" }).GetAwaiter();
            PnpObject hal = awaiter.GetResult();
            string    str;

            string[] versionParts;
            if (hal == null || hal.Properties.ContainsKey("{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3"))
            {
                str = null;
            }
            else
            {
                versionParts = hal.Properties["{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3"].ToString().Split(new char[] { '.' });
                str          = string.Join(".", Enumerable.ToArray <string>(Enumerable.Take <string>(versionParts, 2)));
            }
            return(Task.FromResult <string>(str));
        }