Пример #1
0
        // Grap processor information from registry.
        private void GetProcesorInfo(string cpuInfoWMI, string coresInfo)
        {
            string procInfo = RegistryManagement.regKey_ReadMachine(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString");

            FileSystem.ColorConsoleText(ConsoleColor.Green, "CPU");
            Console.WriteLine($": {procInfo}");
            using (var sRead = new StringReader(cpuInfoWMI))
            {
                string lineCPUCount;
                while ((lineCPUCount = sRead.ReadLine()) != null)
                {
                    if (lineCPUCount.StartsWith("NumberOfProcessors"))
                    {
                        string outParam = "";
                        outParam += lineCPUCount.Split(':')[1];
                        FileSystem.ColorConsoleText(ConsoleColor.Green, $"Physical CPU's");
                        Console.WriteLine($": {outParam}");
                    }
                }
            }
            using (var sRead = new StringReader(coresInfo))
            {
                string lineCoresCount;
                while ((lineCoresCount = sRead.ReadLine()) != null)
                {
                    if (lineCoresCount.StartsWith("NumberOfCores"))
                    {
                        string outParam = "";
                        outParam += lineCoresCount.Split(':')[1];
                        FileSystem.ColorConsoleText(ConsoleColor.Green, $"CPU(s) Cores");
                        Console.WriteLine($": {outParam}");
                    }
                }
            }
            FileSystem.ColorConsoleText(ConsoleColor.Green, $"Logical CPU's");
            Console.WriteLine($": {Environment.ProcessorCount}");
        }