InternetGetConnectedStateExA function (winineti.h)

Note  Using this API is not recommended, use the INetworkListManager::GetConnectivity method instead.
 
Retrieves the connected state of the specified Internet connection.

Syntax

BOOL InternetGetConnectedStateExA(
  [out] LPDWORD lpdwFlags,
  [out] LPSTR   lpszConnectionName,
        DWORD   cchNameLen,
  [in]  DWORD   dwReserved
);

Parameters

[out] lpdwFlags

Pointer to a variable that receives the connection description. This parameter may return a valid flag even when the function returns FALSE. This parameter can be a combination of the following values.

Value Meaning
INTERNET_CONNECTION_CONFIGURED
0x40
Local system has a valid connection to the Internet, but it might or might not be currently connected.
INTERNET_CONNECTION_LAN
0x02
Local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_MODEM
0x01
Local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_MODEM_BUSY
0x08
No longer used.
INTERNET_CONNECTION_OFFLINE
0x20
Local system is in offline mode.
INTERNET_CONNECTION_PROXY
0x04
Local system uses a proxy server to connect to the Internet.

[out] lpszConnectionName

Pointer to a string value that receives the connection name.

cchNameLen

TBD

[in] dwReserved

This parameter is reserved and must be NULL.

Return value

Returns TRUE if there is an Internet connection, or FALSE if there is no Internet connection, or if all possible Internet connections are not currently active. For more information, see the Remarks section.

When InternetGetConnectedState returns FALSE, the application can call GetLastError to retrieve the error code.

Remarks

A return value of TRUE from InternetGetConnectedState indicates that at least one connection to the Internet is available. It does not guarantee that a connection to a specific host can be established. Applications should always check for errors returned from API calls that connect to a server. InternetCheckConnection can be called to determine if a connection to a specific destination can be established.

A return value of TRUE indicates that either the modem connection is active, or a LAN connection is active and a proxy is properly configured for the LAN. A return value of FALSE indicates that neither the modem nor the LAN is connected. If FALSE is returned, the INTERNET_CONNECTION_CONFIGURED flag may be set to indicate that autodial is configured to "always dial" but is not currently active. If autodial is not configured, the function returns FALSE.

Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and destructors of global objects.

Note  WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).
 

Note

The winineti.h header defines InternetGetConnectedStateEx as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winineti.h (include Wininet.h, Winineti.h, Wininet.h, Winineti.h)
Library Wininet.lib
DLL Wininet.dll

See also

Establishing a Dial-Up Connection to the Internet

WinINet Functions