【发布时间】:2008-12-03 09:43:08
【问题描述】:
我从这里“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 速度?
【问题讨论】:
-
嗯.. 是什么让您认为这只适用于 32 位 Windows?
标签: c# .net windows 64-bit cpu-speed