CPU brand stringを表示してみた。
using System.Runtime.Intrinsics.X86; namespace ConsoleApp { class Program { // int[] ascii hex code to string and pirint it static void printIntArray2String(int[] regs) { Console.Write("CPU brand string: "); foreach (int reg in regs) { byte[] bytes = BitConverter.GetBytes(reg); foreach (byte b in bytes) { // Convert the number expressed in base-16 to an integer. int value = Convert.ToInt32(b.ToString("X"), 16); // Get the character corresponding to the integral value. string stringValue = Char.ConvertFromUtf32(value); Console.Write(stringValue); } } Console.WriteLine(""); } // main static void Main(string[] args) { int[] regs = new int[4 * 4]; int nExIds; // Calling __cpuid with 0x80000000 as the InfoType argument // gets the number of valid extended IDs. (nExIds, _, _, _) = X86Base.CpuId(int.MinValue, 0); //0x80000000 // Get the information associated with each extended ID. int p = 0; for (uint i = 0x80000000; i <= (uint)nExIds; ++i) { if (i >= 0x80000002 && i <= 0x80000004) { (regs[p + 0], regs[p + 1], regs[p + 2], regs[p + 3]) = X86Base.CpuId((int)i, 0); p += 4; } } printIntArray2String(regs); } } }
実行例1:
CPU brand string: Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz
実行例2:
CPU brand string: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz
実行例3:
CPU brand string: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz