任何人都知道它是否可以使用本地 IP 地址恢复(主机名/机器名)?我知道解析反向“主机名-> ip”与DeviceNetworkInformation.ResolveHostNameAsync (endpoint, OnNameResolved, null).
是否可以做同样的事情但反过来?给定本地计算机的 IP 并检索其主机名?万分感谢
这是我的代码,但它不起作用主机总是像 ip 一样被称为“192.168.1.5” 。它应该返回“computer0001”
DeviceNetworkInformation.ResolveHostNameAsync("192.168.1.5", OnNameResolved, null);
private void OnNameResolved(NameResolutionResult result)
{
IPEndPoint[] endpoints = result.IPEndPoints;
if (endpoints != null)
{
if (endpoints.Length > 0)
{
//Host always return ip adress and not the machine name
host = endpoints[0].ToString();
}
}
}