开发者

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

开发者 https://www.devze.com 2023-04-06 10:14 出处:网络
I\'m using this code: NetworkInformation.NetworkInterface[] interfaces = NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

I'm using this code:

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

the abo开发者_运维技巧ve 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);
                }
            } 
0

精彩评论

暂无评论...
验证码 换一张
取 消