国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦>學(xué)習(xí)電腦>電腦硬件知識>硬件知識>

    c#怎么獲取硬件信息

    時間: 捷鋒774 分享

      想知道怎么獲取電腦的硬件信息嗎,下面是學(xué)習(xí)啦小編帶來的關(guān)于c #怎么獲取硬件信息的內(nèi)容,歡迎閱讀!

      c #怎么獲取硬件信息?

      /// 獲取系統(tǒng)信息

      ///

      ///

      ///

      /// WMI w = new WMI(WMIPath.Win32_NetworkAdapterConfiguration);

      /// for (int i = 0; i < w.Count; i ++)

      /// {

      /// if ((bool)w[i, "IPEnabled"])

      /// {

      /// Console.WriteLine("Caption:{0}", w[i, "Caption"]);

      /// Console.WriteLine("MAC Address:{0}", w[i, "MACAddress"]);

      /// }

      /// }

      ///

      ///

      public sealed class WMI

      {

      private ArrayList mocs;

      private StringDictionary names; // 用來存儲屬性名,便于忽略大小寫查詢正確名稱。

      ///

      /// 信息集合數(shù)量

      

      public int Count

      {

      get { return mocs.Count; }

      }

      ///

      /// 獲取指定屬性值,注意某些結(jié)果可能是數(shù)組。

      ///

      public object this[int index, string propertyName]

      {

      get

      {

      try

      {

      string trueName = names[propertyName.Trim()]; // 以此可不區(qū)分大小寫獲得正確的屬性名稱。

      Hashtable h = (Hashtable)mocs[index];

      return h[trueName];

      }

      catch

      {

      return null;

      }

      }

      }

      ///

      /// 返回所有屬性名稱。

      ///

      ///

      ///

      public string[] PropertyNames(int index)

      {

      try

      {

      Hashtable h = (Hashtable)mocs[index];

      string[] result = new string[h.Keys.Count];

      h.Keys.CopyTo(result, 0);

      Array.Sort(result);

      return result;

      }

      catch

      {

      return null;

      }

      }

      ///

      /// 返回測試信息。

      ///

      ///

      public string Test()

      {

      try

      {

      StringBuilder result = new StringBuilder(1000);

      for (int i = 0; i < Count; i++)

      {

      int j = 0;

      foreach(string s in PropertyNames(i))

      {

      result.Append(string.Format("{0}:{1}={2}\n", ++j, s, this[i, s]));

      if (this[i, s] is Array)

      {

      Array v1 = this[i, s] as Array;

      for (int x = 0; x < v1.Length; x++)

      {

      result.Append("\t" + v1.GetValue(x) + "\n");

      }

      }

      }

      result.Append("======WMI=======\n");

      }

      return result.ToString();

      }

      catch

      {

      return string.Empty;

      }

      }

    看了"c #怎么獲取硬件信息"文章內(nèi)容的人還看:

    1.c語言怎么獲取硬件信息

    2.linux如何查看硬件信息

    3.WIN7如何查看計算機的硬件配置

    4.查看電腦配置的方法與技巧

    5.電腦開機如何查看顯卡的配置信息

    6.如何查看電腦的配置狀況

    7.學(xué)習(xí)電腦的初步知識

    8.Linux基礎(chǔ):如何找出你的系統(tǒng)所支持的最大內(nèi)存

    9.怎么樣組建局域網(wǎng)

    10.數(shù)據(jù)包接收詳解

    800420