2

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

janneob
  • 929
  • 2
  • 10
  • 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
Sawan
  • 6,353
  • 10
  • 50
  • 101
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,476
  • 2
  • 28
  • 47
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
  • 94,086
  • 102
  • 195
  • 339