Get Cpu Id - CSharp Operating System

CSharp examples for Operating System:Cpu

Description

Get Cpu Id

Demo Code


using System.Management;
using System;// w  w w  . j  a  v a2s  .c  om

public class Main{
        public static string GetCpuId()
        {
            var cpuInfo = string.Empty;
            var mc = new ManagementClass("win32_processor");
            var moc = mc.GetInstances();

            foreach (var o in moc)
            {
                var mo = (ManagementObject) o;
                cpuInfo = mo.Properties["processorID"].Value.ToString();
                break;
            }
            return cpuInfo;
        }
}

Related Tutorials