The following code sample shows how to
use query strings to query WMI programmatically to retrieve Net work connection
details. here bellow code example retrieves connection name and username.
ManagementObjectSearcher MOS;
MOS =
new ManagementObjectSearcher("\\root\\CIMV2",
"SELECT Name,UserName FROM Win32_NetworkConnection");
foreach (ManagementObject mservice
in MOS.Get())
{
Console.WriteLine("Network
Connection:{0}- Connected Username ", mservice["Name"],
mservice["UserName"].ToString());
}