blah blah blah is here! blah blah » Close

up0down
link

Guys, is it possible to check if a network connection has been established then if so perform a function? Something like below (which doesn't work) but i want to check if the local network exists not the internet.

[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
public static bool IsConnectedToInternet()
{
int Desc;
return InternetGetConnectedState(out Desc, 0);
}

private void Form1_Load(object sender, EventArgs e)
{
//Use function
if (IsConnectedToInternet())
{
//MessageBox.Show("Netwok Connection Up");
label1.Text = "Network ok";
}
else
{
//MessageBox.Show("Sorry! Network Connection down.");
label1.Text = "Network Down";
}

}

last answered 2 years ago

1 answers

up2down
link

if thisi s a local network, a good thing u usually do is to ping. try pinging an ip on the network to verify if the network is active or not. here is a link that can help you:

http://www.fryan0911.com/2009/06/c-how-to-ping-remote-computer.html

Thanks muster that helped great, i managed to adapt that code for what i wanted - nice one.

muster
1556

welcome

Feedback