Click to return to the Networking, Protocols     
InternetCreateUrl Functio...     FTP Functions     Uniform Resource Locator ...    
Web Workshop  |  Networking, Protocols & Data Formats

InternetOpenUrl Function


Begins reading a complete FTP, Gopher, or HTTP URL. Use InternetCanonicalizeUrl first if the URL being used contains a relative URL and a base URL separated by blank spaces.

Syntax

HINTERNET InternetOpenUrl(
    IN HINTERNET hInternet, 
    IN LPCTSTR lpszUrl,
    IN LPCTSTR lpszHeaders,
    IN DWORD dwHeadersLength,
    IN DWORD dwFlags,
    IN DWORD_PTR dwContext
);

The actual syntax of this function varies between its ANSI and Unicode implementations. For more information, see Win32 Internet Functions Syntax.

Parameters

hInternet
HINTERNET handle to the current Internet session. The handle must have been returned by a previous call to InternetOpen.
lpszUrl
Address of a string variable that contains the URL to begin reading. Only URLs beginning with ftp:, gopher:, http:, or https: are supported.
lpszHeaders
Address of a string variable that contains the headers to be sent to the HTTP server. (For more information, see the description of the lpszHeaders parameter in the HttpSendRequest function.)
dwHeadersLength
Unsigned long integer value that contains the length, in TCHAR, of the additional headers. If this parameter is -1L and lpszHeaders is not NULL, lpszHeaders is assumed to be zero-terminated (ASCIIZ) and the length is calculated.
dwFlags
Unsigned long integer value that contains the API flags. This can be one of the following values:
INTERNET_FLAG_EXISTING_CONNECT
INTERNET_FLAG_HYPERLINK
INTERNET_FLAG_IGNORE_CERT_CN_INVALID
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
INTERNET_FLAG_KEEP_CONNECTION
INTERNET_FLAG_NEED_FILE
INTERNET_FLAG_NO_AUTH
INTERNET_FLAG_NO_AUTO_REDIRECT
INTERNET_FLAG_NO_CACHE_WRITE
INTERNET_FLAG_NO_COOKIES
INTERNET_FLAG_NO_UI
INTERNET_FLAG_PASSIVE
INTERNET_FLAG_PRAGMA_NOCACHE
INTERNET_FLAG_RAW_DATA
INTERNET_FLAG_RELOAD
INTERNET_FLAG_RESYNCHRONIZE
INTERNET_FLAG_SECURE
dwContext
Address of an unsigned long integer value that contains the application-defined value that is passed, along with the returned handle, to any callback functions.

Return Value

Returns a valid handle to the FTP, Gopher, or HTTP URL if the connection is successfully established, or NULL if the connection fails. To get a specific error message, call GetLastError. To determine why access to the service was denied, call InternetGetLastResponseInfo.

Remarks

This is a general function that an application can use to retrieve data over any of the protocols that the Win32® Internet functions support. This function is especially useful when the application does not need to access the particulars of a protocol, but only requires the data corresponding to a URL. The InternetOpenUrl 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 InternetConnect before InternetOpenUrl.

InternetOpenUrl disables Gopher on ports less than 1024, except for port 70 (the standard Gopher port) and port 105 (typically used for Central Services Organization [CSO] name searches).

Function Information

Windows NT Use version 4.0. Implemented as ANSI and Unicode functions.
Windows Use Windows 95 and later. Implemented as ANSI and Unicode functions.
Header Wininet.h
Import library Wininet.lib
Minimum availability Internet Explorer 3.0 (ANSI only), 5 (ANSI and Unicode)

Windows CE

Windows CE Use version 2.12 and later. Implemented as ANSI and Unicode functions.
Minimum availability Internet Explorer 4.0

See Also

Microsoft Win32 Internet Functions Overview, Handling Uniform Resource Locators, Microsoft Win32 Internet Functions Reference, Uniform Resource Locator (URL) Functions



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.