PDA

View Full Version : system.management در c#2005



group45
دوشنبه 12 بهمن 1388, 07:16 صبح
سلام توی یکی از تایپیکا در مورد بدست آوردن آی پی سی پی یو نوشته بود که با یوزینگ
system.management کار می کرد ولی من همچین چیزی رو تو یوزینگام نمی بینم جریان چیه؟؟؟

Sirwan Afifi
دوشنبه 12 بهمن 1388, 13:25 عصر
public string GetCPUId()
{
string cpuInfo = String.Empty;
//create an instance of the Managemnet class with the
//Win32_Processor class
ManagementClass mgmt = new ManagementClass("Win32_Processor");
//create a ManagementObjectCollection to loop through
ManagementObjectCollection objCol = mgmt.GetInstances();
//start our loop for all processors found
foreach (ManagementObject obj in objCol)
{
if (cpuInfo == String.Empty)
{
// only return cpuInfo from first CPU
cpuInfo = obj.Properties["ProcessorId"].Value.ToString();
}
}
return cpuInfo;
}

Sirwan Afifi
دوشنبه 12 بهمن 1388, 13:29 عصر
برو تو منوی Projects بعد Add Reference تو قسمت.NET اینو دوبار کلیک کن تا به رفرنسات اضافه بشه؟

System.Management