Hi,
I'm using the following code to check if there is a connection to the
internet:
#region
//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int
Description, int ReservedValue);
#endregion
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int Desc;
bool res = InternetGetConnectedState(out Desc, 0);
Console.WriteLine("Inet is up: " + res);
}
The strange thing is that it always returns false, even as I am
writing this message and while browsing the web.
I am connected to the internet via LAN in my company. Maybe this
function is more aimed at modem users ?
Is there any clarification for this ?
Thanks,
JB
Janiek Buysrogge - 30 Aug 2006 14:31 GMT
Hello,
Now I'm using the following code, seems to work:
Solution:
#region
[DllImport("wininet.dll")]
private extern static bool InternetCheckConnection(string
Description, int Flags, int ReservedValue);
#endregion
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
int Desc;
bool res = InternetCheckConnection("http://www.google.be",
1, 0);
Console.WriteLine("Inet is up: " + res);
}
JB
>Hi,
>
[quoted text clipped - 32 lines]
>
>JB