This function allows an application to check if a connection to the Internet can be established.

BOOL InternetCheckConnection(
  LPCTSTR lpszUrl,
  DWORD dwFlags,
  DWORD dwReserved


  • lpszUrl
    [in] Pointer to a string containing the URL to use to check the connection. This value can be set to NULL.

  • dwFlags
    [in] Unsigned long integer value containing the flag values. FLAG_ICC_FORCE_CONNECTION is the only flag that is currently available. If this flag is set, it forces a connection. A sockets connection is attempted in the following order.

    If lpszUrl is non-NULL, the host value is extracted from it and used to ping that specific host.

    If lpszUrl is NULL and there is an entry in the WinInet internal server database for the nearest server, the host value is extracted from the entry and used to ping that server.

  • dwReserved
    [in] Reserved. Must be set to zero.

Return Values

Returns TRUE if a connection is made successfully, or FALSE otherwise. Use GetLastError to retrieve the error code. ERROR_NOT_CONNECTED is returned by GetLastError if a connection cannot be made or if the sockets database is unconditionally offline.


OS Versions: Windows CE .NET 4.0 and later.
Header: Wininet.h.
Link Library: Wininet.lib.

See Also

WinInet Functions

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.