Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

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

Syntax

BOOL InternetCheckConnection(
  LPCTSTR 
lpszUrl,
  DWORD 
dwFlags,
  DWORD 
dwReserved
);

Parameters

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 lpszUrlis non-NULL, the host value is extracted from it and used to ping that specific host.

If lpszUrlis 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 Value

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

Requirements

Header wininet.h
Library wininet.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

WinInet Functions