IP Adresse, Subnetmask, Default Gateway, NIC, Netzwerkkarte, MAC Adresse abfragen
using System.Management;
string[] Adressen;
string[] SubnetMasken;
string[] DefaultGateways;
string NetworkCard;
string MACAddress;
ManagementObjectSearcher NetworkInfo = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection MOC = NetworkInfo.Get();
foreach (ManagementObject mo in MOC)
{
Adressen = (string[])mo["IPAddress"];
SubnetMasken = (string[])mo["IPSubnet"];
DefaultGateways = (string[])mo["DefaultIPGateway"];
NetworkCard = mo["Description"].ToString();
MACAddress = mo["MACAddress"].ToString();
}
3 Kommentare zum Snippet