1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| ManagementClass mc2 = new ManagementClass("Win32_NetworkAdapter");
ManagementObjectCollection mcCol2 = mc2.GetInstances();
foreach (ManagementObject mcObj2 in mcCol2)
{
if (mcObj2["MACAddress"] != null)
{
string LeMac = mcObj2["MACAddress"].ToString();
if ((LeMac.IndexOf(Macadd) != -1) && (trouvee==false))
{
try
{
vitesse=Convert.ToString(Convert.ToInt64(mcObj2["Speed"].ToString()) / (1000 * 1000)); // en Mbits, vitesse "instantanée"
trouvee = true;
}
catch { }
}
}
}
string Macsimple = Macadd;
Macsimple = Macsimple.Replace(":","");
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
if (nics == null || nics.Length < 1) { return; }
foreach (NetworkInterface adapter in nics)
{
IPInterfaceProperties properties = adapter.GetIPProperties();
if (Macsimple == adapter.GetPhysicalAddress().ToString())
{
IPv4InterfaceStatistics stats = adapter.GetIPv4Statistics();
if (adapter.Speed != -1)
{ vitessemax=Convert.ToString(adapter.Speed / (1000 * 1000)); } // en Mbits, vitesse du réseau
}
} |
Partager