程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> C#獲取磁盤及CPU的序列號

C#獲取磁盤及CPU的序列號

編輯:C#入門知識

//獲取磁盤序列號
try
{
  System.Management.ManagementObjectSearcher   cmicWmi   =   new   ManagementObjectSearcher                     ( "SELECT   *   FROM   Win32_DiskDrive ");
  System.UInt32   tmpUint32   =   0;
  foreach(ManagementObject   cmicWmiObj   in   cmicWmi.Get())
  {
    tmpUint32   =   Convert.ToUInt32(cmicWmiObj[ "signature "].ToString());
  }
  this.textBox1.Text   =   tmpUint32.ToString();
  this.gProgressBar1.Value   ++;
}
catch(Exception   ex1)
{
  throw   new   Exception(ex1.ToString());
}
//獲取cpu序列號
try
{
  System.Management.ManagementObjectSearcher   Wmi   =   new   ManagementObjectSearcher                   ( "SELECT   *   FROM   Win32_Processor ");
  string   tmpUint32_1   =   string.Empty;
  foreach(ManagementObject   WmiObj   in   Wmi.Get())
  {
    tmpUint32_1   =WmiObj[ "ProcessorId "].ToString();
  }
  this.textBox2.Text   =   tmpUint32_1;
  this.gProgressBar1.Value   ++;
}
catch(Exception   ex2)
{
  throw   new   Exception(ex2.ToString());
}

      

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved