List of Windows network connections / profiles in C #

Can anyone point me to a class to list the current network profiles installed on a Windows machine (XP, Vista, 7,8,8.1) in C #?

I basically want a list of the following along with the connection status:

Windows network connections

I looked at the function NetworkInterface.GetAllNetworkInterfaces()

, but obviously just returns physical adapters, I'm looking for network profiles.

+3


source to share


1 answer


You can do this using the Network List Manager API , which allows applications to fetch a list of available network connections. The Windows.Net API code wraps this API so that it can be easily used by managed applications. Add NuGet package

Windows Code Code - Core



Call the following function to display network profiles:

public void ListNetworkProfiles()
{
    NetworkCollection nCollection = NetworkListManager.GetNetworks(NetworkConnectivityLevels.All);
    foreach (Network net in nCollection)
    {
        Console.WriteLine("Name: " + net.Name + " Status: " + (net.IsConnected ? "Connected" : "Not Connected"));
    }
}

      

+3


source







All Articles