Blog

Filter posts by Category Or Tag of the Blog section!

How to get CPU Id by using C# with .Net classes

Friday, 08 November 2013

By using ManagementObjectSearcher class in System.Management; namespace you can get your hardware information such as CPU Id. take a look at this piece of code:

 

  static void Main(string[] args)
        {
            var managementObjectSearcher = new ManagementObjectSearcher("SELECT ProcessorId FROM Win32_Processor");
            var oCollection = managementObjectSearcher.Get();
            foreach (ManagementObject item in oCollection)
            {
                var myProcessor = (string)item["ProcessorId"];
                Console.WriteLine("Processor Id: {0}", myProcessor);
            }
        }

 

Have fun!

 

Category: Software

Tags: C#

comments powered by Disqus