zoukankan      html  css  js  c++  java
  • 获取主板物理网卡地址

    //获取主板物理网卡地址
    public static string GetNetwork()
    {
    string strMac = null;
    NetworkInterface[] fNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in fNetworkInterfaces)
    {
    string fRegistryKey = "SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" + adapter.Id + "\Connection";
    RegistryKey rk = Registry.LocalMachine.OpenSubKey(fRegistryKey, false);
    if (rk != null)
    {
    string fPnpInstanceID = rk.GetValue("PnpInstanceID", "").ToString();
    //int fMediaSubType = Convert.ToInt32(rk.GetValue("MediaSubType", 0));
    if (fPnpInstanceID.Length > 3 && fPnpInstanceID.Substring(0, 3) == "PCI")
    {
    if (adapter.GetPhysicalAddress() != null)
    {
    strMac = adapter.GetPhysicalAddress().ToString();
    }
    }
    //else
    //{
    // if (fMediaSubType == 2)
    // {
    // //无线网卡
    // }
    // if (fMediaSubType == 1)
    // {
    // //虚拟网卡
    // }
    //}
    }
    }

    if (strMac != null)
    {
    return strMac.ToLower();
    }
    else
    {
    return "";
    }
    }

  • 相关阅读:
    C#调用Matlab程序
    一台电脑,内外网同时使用
    django 表反查
    django 反查
    登录注册
    django forms自带form表单
    django url 中name
    关于django无法加载静态css、js的情况
    django static
    django models,views,urls,settings
  • 原文地址:https://www.cnblogs.com/zhasen/p/3440998.html
Copyright © 2011-2022 走看看