不想通过dhcpsapi.dll调用,因为我不想仅限于Windows DHCP服务器。 有没有其他方法通过C#获取DHCP信息
您可以使用WMI和Win32_NetworkAdapterConfiguration类。 返回的可用字段之一是DNSHostName,它似乎是DHCP选项15。
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'") ;
ManagementObjectCollection queryCollection = query.Get();
foreach( ManagementObject mo in queryCollection )
{
string dnsName = (string[])mo["DNSHostName"];
Console.WriteLine("IP Address: {0}", ipaddress);
}
标签:15,Option,NetworkAdapterConfiguration,ManagementObjectSearcher,query,DHCP From: https://www.cnblogs.com/dhcpclass/p/17103366.html