How to get CPU frequency in c#

前端 未结 5 665
自闭症患者
自闭症患者 2020-12-03 09:17

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 :)

5条回答
  •  旧时难觅i
    2020-12-03 09:44

     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

提交回复
热议问题