I have an application on Windows CE 5.0 and Windows Mobile 5.0 where I am currently fetching the IP address using the following code:
IPHostEntry dnsEntry = Dns.GetHostEntry(_host);
foreach (IPAddress ia in dnsEntry.AddressList)
{
if (ia.AddressFamily == AddressFamily.InterNetwork)
{
_address = ia;
break;
}
}
where "_host" is the hostname that is fetched from an XML config file. My question now is how do I see the remaining lease time for the IP address "_address"?
I'm leaving the previous answer as it may be useful for somebody else, but I think it's possible on Windows CE 5.0, using IP Helper API.
First, take a look at Managing Network Adapters (Windows CE 5.0).
You'll use the GetAdaptersInfo function.
It returns an IP_ADAPTER_INFO structure, that has an
LeaseExpiresproperty.Don't know if you ever used Windows API on C# before. It's a little ugly but you get used to it, and as long as it works, it's fine! =D
PInvoke.NET has a good example on how to use it. Don't know if it's related to the desktop or CE version, but I think you can manage to make it work.
It would be something like: