internetcheckconnection (wininet)
Last changed: anonymous

.
Summary
Allows an application to check if a connection to the Internet can be established.

C# Signature:

[DllImport("wininet.dll", SetLastError = true)]
static extern bool InternetCheckConnection(string lpszUrl, int dwFlags, int dwReserved);

VB Signature:

Declare Function InternetCheckConnection Lib "wininet.dll" (ByVal lpszUrl As String, ByVal dwFlags As Integer, ByVal dwReserved As Integer) As Boolean

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

There are noted problems from some users using this function when the computer is behind a proxy.

Tips & Tricks:

Please add some!

Sample Code:

[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetCheckConnection(string lpszUrl, int dwFlags, int dwReserved);

bool connectivity;
if (InternetCheckConnection("http://www.google.com/", 1, 0))
{
     connectivity = true;
}

Documentation