C # performance counter and username

The perfmon counter uses different NIC names compared to ipconfig / all and the C # system call, as you can see below (this is from ipconfig / all)

   Ethernet adapter HHHH:       

   Connection-specific DNS Suffix  . :   

   Description . . . . . . . . . . . : HP NC364T PCIe Quad Port Gigabit Server Adapter #3
   Physical Address. . . . . . . . . : 00-1F-29-0D-26-59
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 166.49.47.10(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.240
   Default Gateway . . . . . . . . . :
   NetBIOS over Tcpip. . . . . . . . : Disabled
using System.Net.NetworkInformation;
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();

I get it HP NC364T PCIe Quad Port Gigabit Server Adapter #3. Just like ipconfig. BUT , perfmon uses HP NC364T PCIe Quad Port Gigabit Server Adapter _3(underscore instead of hash). Should I use a different call to get the exact exact counter name that perfmon has? If so, what is it?

+5
source share
1 answer

, -. , , . ( ). Windows Vista 32/64 7. NET, , . " Microsoft.Win32".

private void button1_Click(object sender, EventArgs e)
    {
        ListPCIDevices(false, listBox1);
    }

    public static void ListPCIDevices(bool ListOnlyNetworkDevices, ListBox LB)
    {
        string NetKey = @"SYSTEM\ControlSet001\Enum\PCI";
        using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(NetKey))
        {
            foreach (string skName in rk.GetSubKeyNames())
            {
                using (RegistryKey sk = rk.OpenSubKey(skName))
                {

                    foreach (string skSubName in sk.GetSubKeyNames())
                    {

                        using (RegistryKey ssk = sk.OpenSubKey(skSubName))
                        {

                            object ItemName = ssk.GetValue("DeviceDesc");
                            object ItemCat = ssk.GetValue("Class");
                            if (ItemCat == null) { ItemCat = "Unknown"; }

                            if ((ItemName != null) && ((ItemCat.ToString() == "Net")||(!ListOnlyNetworkDevices)))
                            {
                                LB.Items.Add(ItemName.ToString().Split(';')[1]);
                            }

                        }
                    }
                }
            }
        }
    }
+1

All Articles