How do I get the CPU speed and total physical ram in C#?

Posted by edude05 on Stack Overflow See other posts from Stack Overflow or by edude05
Published on 2010-06-10T18:14:46Z Indexed on 2010/06/10 18:22 UTC
Read the original article Hit count: 229

Filed under:
|
|

I need a simple way of checking how much ram and fast the CPU of the host PC is. I tried WMI however the code I'm using

 private long getCPU()
 {
    ManagementClass mObject = new ManagementClass("Win32_Processor");
    mObject.Get();
    return (long)mObject.Properties["MaxClockSpeed"].Value;

 }

Throws a null reference exception. Furthermore, WMI queries are a bit slow and I need to make a few to get all the specs. Is there a better way?

© Stack Overflow or respective owner

Related posts about c#

Related posts about wmi