0

I'm using Windows XP and I want to know if the local area is available or not?

And if I'm using another OS would that affect on my code?

BDeveloper
  • 1,175
  • 6
  • 24
  • 44
  • Which language are you using? Do you need win32 API calls or managed libraries? – OJ. Dec 13 '08 at 09:08

4 Answers4

0

Use the following code

using System.Net.NetworkInformation; //(Add reference of System.Net.dll)
public partial class Form1: Form
{
    public Form1()
    {
        InitializeComponent();
        NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
    }
    private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
    {
        if(e.IsAvailable)
        {
            //connected
        }
        else
        {
            //disconnected
        }
    }
}
NASSER
  • 5,900
  • 7
  • 38
  • 57
0

And if I'm using another OS would that affect on my code?

In most cases, yes, unless you consider various versions of Windows to be "another OS".

The networking interfaces of the operating systems vary, because the API's area extensions of the primary language and architecture of the OS.

benc
  • 1,381
  • 5
  • 31
  • 39
-1

The source code for ToggleNic shows you how to enable, disable or check for available network connections on windows. This is in C#.

kit
  • 1,166
  • 5
  • 16
  • 23
Agnel Kurian
  • 57,975
  • 43
  • 146
  • 217
-1

Here's how to do it in Delphi.

Community
  • 1
  • 1
Mick
  • 13,248
  • 9
  • 69
  • 119