Ehsan Ghanbari

Experience, DotNet, Solutions

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

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:


  1.        static void Main(string[] args)
  2.         {
  3.             var managementObjectSearcher = new ManagementObjectSearcher("SELECT ProcessorId FROM Win32_Processor");
  4.             var oCollection = managementObjectSearcher.Get();
  5.             foreach (ManagementObject item in oCollection)
  6.             {
  7.                 var myProcessor = (string)item["ProcessorId"];
  8.                 Console.WriteLine("Processor Id: {0}", myProcessor);
  9.             }
  10.         }

Have fun!


About Me

Ehsan Ghanbari

Hi! my name is Ehsan. I'm a developer, passionate technologist, and fan of clean code. I'm interested in enterprise and large-scale applications architecture and design patterns. I spend a lot of time on software architecture. Since 2008, I've been as a developer for different companies and organizations and I've been focusing on Microsoft ecosystem all the time. During the past years, Read More

Post Tags
Pending Blog Posts
using Elmah in MVC4
Using FluentSecurity in MVC
Strategic design
Factory Pattern
time out pattern in ajax
Redis as a cache server
How to use PagedList In MVC
Multiple submit buttons in MVC
Domain driven design VS model driven architecture
What's the DDD-lite?
comments powered by Disqus