2

What is the way to find out if the LAN connection is up or down in wince 7 with c++ or c#?

janneob
  • 959
  • 2
  • 11
  • 25

3 Answers3

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();
Community
  • 1
  • 1
Saw
  • 6,199
  • 11
  • 53
  • 104
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