我从这里找到了以下代码“http://www.boyet.com/Articles/CodeFromInternet.html "。
它以 GHz 为单位返回 CPU 的速度,但仅适用于 32 位 Windows。
using System;
using System.Management;
namespace CpuSpeed
{
class Program
{
static double? GetCpuSpeedInGHz()
{
double? GHz = null;
using (ManagementClass mc = new ManagementClass("Win32_Processor"))
{
foreach (ManagementObject mo in mc.GetInstances())
{
GHz = 0.001 * (UInt32) mo.Properties["CurrentClockSpeed"].Value;
break;
}
}
return GHz;
}
static void Main(string[] args)
{
Console.WriteLine("The current CPU speed is {0}", (GetCpuSpeedInGHz() ?? -1.0).ToString());
Console.ReadLine();
}
}
}
我搜索了 64 位管理类,但没有成功。
有没有其他方法可以在 64 位 Windows 下获得 CPU 速度?