简体   繁体   中英

How I can get All Network Interfaces(including that are not running)?

I'm using this code:

NetworkInformation.NetworkInterface[] interfaces = NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

the above code retrieving only the active network connections, I need of all. How I do this? Thanks in advance. :)

using System.Management;   



    ManagementObjectSearcher query = new ManagementObjectSearcher(   
        "SELECT * FROM Win32_NetworkAdapterConfiguration" );   
    ManagementObjectCollection queryCollection = query.Get();   

    foreach (ManagementObject mo in queryCollection)   
    {   
        Console.WriteLine(mo["Description"].ToString());
    }   

Edit:

to find all others ["Properties"] name, change the foreach like this:

foreach (ManagementObject mo in queryCollection) 
            {

                foreach (PropertyData pd in mo.Properties)
                {
                    Console.WriteLine(pd.Name);
                }
            } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM