private void btnCheckConnection_Click(objectsender, EventArgs e)
{
int Description=0;
bool isConnected
= InternetGetConnectedState(out Description,
0);
if (isConnected
== true)
{
label1.Text = "User
is Connected to Internet ";
}
else
{
label1.Text = "Disconnected";
}
}
Here is how complete code look like
-----------------------------------------------
public partial class Form1 : Form
{
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int connectionDescription,int reservedValue);
public Form1()
{
InitializeComponent();
}
private void btnCheckConnection_Click(object sender, EventArgs e)
{
int Description=0;
bool isConnected
= InternetGetConnectedState(out Description,
0);
if (isConnected
== true)
{
label1.Text = "User
is Connected to Internet ";
}
else
{
label1.Text = "Disconnected";
}
}
}
Thank you.