日期:2014-05-17 浏览次数:21127 次
ObjectQuery oq = new ObjectQuery("select * from Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ObjectQuery oq = new ObjectQuery("select * from Win32_NetworkAdapterConfiguration ");
public static void ShowNetworkInterfaceMessage()
{
NetworkInterface[] fNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in fNetworkInterfaces)
{
#region " 网卡类型 "
string fCardType = "未知网卡";
string fRegistryKey = "SYSTEM//CurrentControlSet//Control//Network//{4D36E972-E325-11CE-BFC1-08002BE10318}//" + adapter.Id + "//Connection";
RegistryKey rk = Registry.LocalMachine.OpenSubKey(fRegistryKey, false);
if (rk != null)
{
// 区分 PnpInstanceID
// 如果前面有 PCI 就是本机的真实网卡
// MediaSubType 为 01 则是常见网卡,02为无线网卡。
string fPnpInstanceID = rk.GetValue("PnpIn