當前位置:編程學習大全網 - 網站源碼 - c#獲取網卡信息並且用combbox選擇並顯示出來

c#獲取網卡信息並且用combbox選擇並顯示出來

代碼如下:

using?System;

using?System.Drawing;

using?System.Windows.Forms;

using?System.Management;?//必須在項目中添加System.Management引用!

using?System.Collections.Generic;

namespace?WindowsFormsApplication1

{

public?partial?class?Form1?:?Form

{

public?Form1()

{

InitializeComponent();

comboBox1.DropDownStyle?=?ComboBoxStyle.DropDownList;

comboBox1.Items.AddRange(GetNetcardName().ToArray());

}

//?獲取計算機上安裝的網卡名稱

private?List<string>?GetNetcardName()

{

List<string>?cardNames?=?new?List<string>();

ManagementClass?mc?=?

new?ManagementClass("Win32_NetworkAdapter");

ManagementObjectCollection?moc?=?mc.GetInstances();

foreach?(ManagementObject?mo?in?moc)

{

cardNames.Add(mo["Description"].ToString());

}

return?cardNames;

}

}

}

  • 上一篇:怎麽判斷過期疫苗如何判斷過期疫苗
  • 下一篇:求ps教程下載 或者網址 要求要全 齊全~~
  • copyright 2024編程學習大全網