如何在C#項(xiàng)目中獲取硬件參數(shù)-創(chuàng)新互聯(lián)

如何在C#項(xiàng)目中獲取硬件參數(shù)?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。

員工經(jīng)過(guò)長(zhǎng)期磨合與沉淀,具備了協(xié)作精神,得以通過(guò)團(tuán)隊(duì)的力量開(kāi)發(fā)出優(yōu)質(zhì)的產(chǎn)品。創(chuàng)新互聯(lián)堅(jiān)持“專注、創(chuàng)新、易用”的產(chǎn)品理念,因?yàn)椤皩W⑺詫I(yè)、創(chuàng)新互聯(lián)網(wǎng)站所以易用所以簡(jiǎn)單”。公司專注于為企業(yè)提供成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、微信公眾號(hào)開(kāi)發(fā)、電商網(wǎng)站開(kāi)發(fā),微信小程序開(kāi)發(fā),軟件按需網(wǎng)站策劃等一站式互聯(lián)網(wǎng)企業(yè)服務(wù)。

C# 獲取硬件參數(shù)的實(shí)現(xiàn)方法

示例代碼:

private static string GetIdentifier(string wmiClass, string wmiProperty, string wmiMustBeTrue) 
    { 
      string result = ""; 
      System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass); 
      System.Management.ManagementObjectCollection moc = mc.GetInstances(); 
      foreach (System.Management.ManagementObject mo in moc) 
      { 
        if (mo[wmiMustBeTrue].ToString() == "True") 
        { 
          //Only get the first one 
          if (result == "") 
          { 
            try 
            { 
              result = mo[wmiProperty].ToString(); 
              break; 
            } 
            catch 
            { 
            } 
          } 
        } 
      } 
      return result; 
    } 
 
 
    private static string GetIdentifier(string wmiClass, string wmiProperty) 
    { 
      string result = ""; 
      System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass); 
      System.Management.ManagementObjectCollection moc = mc.GetInstances(); 
      foreach (System.Management.ManagementObject mo in moc) 
      { 
        //Only get the first one 
        if (result == "") 
        { 
          try 
          { 
            result = mo[wmiProperty].ToString(); 
            break; 
          } 
          catch 
          { 
          } 
        } 
      } 
      return result; 
    } 
 
 
 
 
 
 
// cpu id  
GetIdentifier("Win32_Processor", "UniqueId"); 
 
 
//processor id 
GetIdentifier("Win32_Processor", "ProcessorId"); 
 
 
//processor name 
GetIdentifier("Win32_Processor", "Name"); 
 
 
 
 
//Manufacturer 
GetIdentifier("Win32_Processor", "Manufacturer"); 
 
 
 
 
//BIOS Identifier 
    private static string GetBiosId() 
    { 
      return GetIdentifier("Win32_BIOS", "Manufacturer") 
      + GetIdentifier("Win32_BIOS", "SMBIOSBIOSVersion") 
      + GetIdentifier("Win32_BIOS", "IdentificationCode") 
      + GetIdentifier("Win32_BIOS", "SerialNumber") 
      + GetIdentifier("Win32_BIOS", "ReleaseDate") 
      + GetIdentifier("Win32_BIOS", "Version"); 
    } 
    //Main physical hard drive ID 
    private static string GetDiskId() 
    { 
      return GetIdentifier("Win32_DiskDrive", "Model") 
      + GetIdentifier("Win32_DiskDrive", "Manufacturer") 
      + GetIdentifier("Win32_DiskDrive", "Signature") 
      + GetIdentifier("Win32_DiskDrive", "TotalHeads"); 
    } 
    //Motherboard ID 
    private static string GetBaseId() 
    { 
      return GetIdentifier("Win32_BaseBoard", "Model") 
      + GetIdentifier("Win32_BaseBoard", "Manufacturer") 
      + GetIdentifier("Win32_BaseBoard", "Name") 
      + GetIdentifier("Win32_BaseBoard", "SerialNumber"); 
    } 
    //Primary video controller ID 
    private static string GetVideoId() 
    { 
      return GetIdentifier("Win32_VideoController", "DriverVersion") 
      + GetIdentifier("Win32_VideoController", "Name"); 
    } 
    //First enabled network card ID 
    private static string GetMacId() 
    { 
      return GetIdentifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled"); 
    }

看完上述內(nèi)容,你們掌握如何在C#項(xiàng)目中獲取硬件參數(shù)的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站制作公司行業(yè)資訊頻道,感謝各位的閱讀!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)站題目:如何在C#項(xiàng)目中獲取硬件參數(shù)-創(chuàng)新互聯(lián)
文章鏈接:http://muchs.cn/article36/ipdsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站建設(shè)做網(wǎng)站、App開(kāi)發(fā)品牌網(wǎng)站制作、定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)