实际上我试图获取适用于Windows应用商店的LAN的IP地址列表 使用Xaml和C#的应用程序。可以任何人请告诉我如何执行此操作并引用此链接How to get LocalNetwork IP Address For WindowsStore Apps但它显示本地计算机IP地址但我想要连接到LAN中本地服务器的已连接主机名和IP地址列表。这是我的代码:
var hostNamesList = Windows.Networking.Connectivity.NetworkInformation
.GetHostNames();
foreach (var entry in hostNamesList)
{
if (entry.Type == Windows.Networking.HostNameType.DomainName)
{
var icp = NetworkInformation.GetInternetConnectionProfile();
if (icp != null && icp.NetworkAdapter != null)
{
var hostname =
NetworkInformation.GetHostNames().SingleOrDefault(
hn =>
hn.IPInformation != null &&
hn.IPInformation.NetworkAdapter.NetworkAdapterId ==
icp.NetworkAdapter.NetworkAdapterId);
MessageDialog msg = new MessageDialog(hostname.CanonicalName);
await msg.ShowAsync();
MessageDialog msg1 = new MessageDialog(entry.RawName);
await msg1.ShowAsync();
}
}
}
}