You can use Network List Manager
// Add reference to : Network List Manager 1.0 Type Library
// Add : using NETWORKLIST;
A test :
NetworkListManager nlm = new NetworkListManager();
IEnumNetworks networks = nlm.GetNetworks(NLM_ENUM_NETWORK.NLM_ENUM_NETWORK_CONNECTED);
foreach (INetwork netw in networks)
{
Console.WriteLine("Connected Network : " + netw.GetName() + " - Internet : " + netw.IsConnectedToInternet.ToString());
foreach (INetworkConnection nc in netw.GetNetworkConnections())
{
string sIP = GetIPFromAdapter("{" + nc.GetAdapterId().ToString() + "}");
if (sIP != null)
{
Console.WriteLine(sIP);
}
}
}
Utility function (remove static if not needed) :
static public string GetIPFromAdapter(string sAdapterID)
{
string sRet = null;
foreach (System.Net.NetworkInformation.NetworkInterface ni in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
{
if (ni.Id.Equals(sAdapterID, StringComparison.CurrentCultureIgnoreCase))
{
foreach (System.Net.NetworkInformation.UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
{
if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
sRet = ip.Address.ToString();
break;
}
}
}
}
return sRet;
}