What is the way to find out if the LAN connection is up or down in wince 7 with c++ or c#?
Asked
Active
Viewed 1,351 times
3 Answers
1
You can use ipConfig command line tool from your c# or c++ application, it provides the status of all network adapters.
This question may be useful: Checking network status in C#
bool networkUp = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
-
I can't access System.Net.NetworkInformation, I added system.dll, I need to add any other dll? – janneob Dec 16 '12 at 13:37
-
1this function isn't available in the .NET CF, which is what the author would be using. – pdriegen Dec 17 '12 at 15:49
-
Always, my simple solutions got reputation! – Saw Dec 19 '12 at 10:36
0
Try this:
try
{
System.Net.IPHostEntry entry = System.Net.Dns.GetHostByName("hostname");
// found host
}
catch(System.Net.Socket.SocketException)
{
//host not found == LAN not connected!
}

Obama
- 2,586
- 2
- 30
- 49
0
You can use NetworkChange
class in .NET. For Lan connection, use NetworkInterface.GetIsNetworkAvailable()
method.
Return Value
Type: System.Boolean
true if a network connection is available; otherwise, false.
Also take a look those;
System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged
System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged

Soner Gönül
- 97,193
- 102
- 206
- 364
-
I can't access System.Net.NetworkInformation, I added system.dll, I need to add any other dll? – janneob Dec 16 '12 at 13:50
-
Did you add as a namespace `using System.Net.NetworkInformation;` ? – Soner Gönül Dec 16 '12 at 18:44