Network detection in CF 2.0?

J

Jeppe Jespersen

I want my PPC app to be "network aware". Question is in two parts

1. How can i determine if the PPC in on a network?

2. How can i be alerted automatically, when network is detected?

Any ideas?

Jeppe Jespersen
Denmark
 
L

Lonifasiko

1. If you want to check if the PDA has network connectivity:

public static bool HasNetworkConnectivity()
// Call this class as follows: bool bResponse =
Net.IsWebAccessible;
{
HttpWebRequest hwrRequest;
HttpWebResponse hwrResponse;
string strUrl = @"http://www.microsoft.com/";
bool bConnected = false;
try
{
hwrRequest = (HttpWebRequest)WebRequest.Create(strUrl);
hwrResponse =
(HttpWebResponse)hwrRequest.GetResponse();
if (hwrResponse.StatusCode == HttpStatusCode.OK)
{
bConnected = true;
}
hwrResponse.GetResponseStream().Close();
}
catch (WebException we)
{
bConnected = false;
}
catch (Exception ex)
{
bConnected = false;
}
finally
{
hwrRequest = null;
hwrResponse = null;
}
return bConnected;
}

Take also a look at ConnectionManager from OpenNETCF. I think it gives
you the ability to enumerate all connections of the device. If you need
that, tell me so that I can show you some code.

Hope it helps.

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top