How to get CPU frequency in c#

Orpheo picture Orpheo · Aug 3, 2011 · Viewed 14.4k times · Source

How can I get in c# the CPU frequency (example : 2Ghz) ? It's simple but I don't find it in the environnement variables. Thanks :)

Answer

wiero picture wiero · Aug 3, 2011
 var searcher = new ManagementObjectSearcher(
            "select MaxClockSpeed from Win32_Processor");
 foreach (var item in searcher.Get())
 {
      var clockSpeed = (uint)item["MaxClockSpeed"];
 }

if you wish to get other fields look at class Win32_processor