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 begins reading a complete FTP or HTTP Universal Resource Locator (URL). For a relative URL and a base URL separated by blank spaces, InternetCanonicalizeUrlmust be invoked first.

Syntax

HINTERNET InternetOpenUrl( 
  HINTERNET 
hInternetSession, 
  LPCTSTR 
lpszUrl, 
  LPCTSTR 
lpszHeaders, 
  DWORD 
dwHeadersLength, 
  DWORD 
dwFlags, 
  DWORD 
dwContext
);

Parameters

hInternetSession

[in] Handle to the current Internet session. The handle must have been returned by a previous call to InternetOpen.

lpszUrl

[in] Long pointer to a null-terminated string that contains the URL to begin reading. Only URLs beginning with ftp:, http:, or https: are supported.

lpszHeaders

[in] Long pointer to a null-terminated string that contains the headers to be sent to the HTTP server. (For more information, see the description of the lpszHeadersparameter in the HttpSendRequestfunction.)

dwHeadersLength

[in] Specifies the length, in characters, of the additional headers. If this parameter is -1L and lpszHeadersis not NULL, lpszHeadersis assumed to be zero-terminated (ASCIIZ) and the length is calculated. The length of header must not include the null terminator at the end of the string. If the null character is included, the headers will not be parsed correctly.

dwFlags

[in] Specifies a bitmask of action flags. The following table shows the possible values.

Value Description

INTERNET_FLAG_EXISTING_CONNECT

If possible, reuses the existing connections to the server for new requests generated by InternetOpenUrlinstead of creating a new session for each request. This flag is useful only for FTP connections, because FTP is the only protocol that typically performs multiple operations during the same session. The WinInet function caches a single connection handle for each HINTERNET handle generated by InternetOpen.

INTERNET_FLAG_RAW_DATA

Returns the data as a WIN32_FIND_DATAstructure when retrieving FTP directory information. If this flag is not specified or if the call was made through a CERN proxy, InternetOpenUrlreturns an HTML version of the directory.

dwContext

[in] Application-defined value that is passed, along with the returned handle, to any callback functions.

Return Value

A valid handle to the FTP or HTTP URL indicates that the connection is successfully established. NULL indicates that the connection fails. To get extended error information, call GetLastError. To determine why access to the service was denied, call InternetGetLastResponseInfo.

Remarks

Windows Embedded CE supports only FTP and HTTP protocols. Only URLs beginning with FTP:, HTTP:, or secure HTTP (HTTPS:): are supported.

The following list shows the values that Windows Embedded CE supports for the dwFlagsparameter:

  • INTERNET_FLAG_RAW_DATA

  • INTERNET_FLAG_RELOAD

  • INTERNET_FLAG_SECURE

The dwContextparameter allows for progress status callbacks to the application, but all requests are handled synchronously.

When establishing a Secure Sockets Layer (SSL) or Transport Layer Security, two options can be used in InternetOpenUrlto ignore invalid certificate errors. The following table shows these values.

Value Description

INTERNET_FLAG_IGNORE_CERT_CN_INVALID

This ignores errors caused when the certificate host name of the server does not match the host name in the request.

INTERNET_FLAG_IGNORE_CERT_DATE_INVALID

This ignores errors caused by an expired server certificate.

InternetOpenUrlis a general function that an application can use to retrieve data over any of the protocols that the WinInet functions support. This function is particularly useful when the application does not need to access the particulars of a protocol, but only requires the data corresponding to a URL. The function parses the URL string, establishes a connection to the server, and prepares to download the data identified by the URL. The application can then use InternetReadFile(for files) or InternetFindNextFile(for directories) to retrieve the URL data. It is not necessary to call InternetConnectbefore InternetOpenUrl.

Use InternetCloseHandleto close the handle returned from InternetOpenUrl. However, note that closing the handle before all the URL data has been read results in the connection being terminated.

Requirements

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

See Also