六月丁香五月婷婷,丁香五月婷婷网,欧美激情网站,日本护士xxxx,禁止18岁天天操夜夜操,18岁禁止1000免费,国产福利无码一区色费

學(xué)習(xí)啦>學(xué)習(xí)電腦>電腦硬件知識(shí)>硬件知識(shí)>

c#怎么獲取硬件信息

時(shí)間: 捷鋒774 分享

  想知道怎么獲取電腦的硬件信息嗎,下面是學(xué)習(xí)啦小編帶來(lái)的關(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; // 用來(lái)存儲(chǔ)屬性名,便于忽略大小寫(xiě)查詢正確名稱。

  ///

  /// 信息集合數(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ū)分大小寫(xiě)獲得正確的屬性名稱。

  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;

  }

  }

  ///

  /// 返回測(cè)試信息。

  ///

  ///

  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語(yǔ)言怎么獲取硬件信息

2.linux如何查看硬件信息

3.WIN7如何查看計(jì)算機(jī)的硬件配置

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

5.電腦開(kāi)機(jī)如何查看顯卡的配置信息

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

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

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

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

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

800420