InternetOpenA function (wininet.h)
Initializes the WinInet service.
Overview
The InternetOpenA function initializes the application to use the WinInet API. It informs the WinInet service of the application's presence and allows the application to specify the context and behavior of its Internet sessions.
Syntax
HINTERNET InternetOpenA(
[in, optional] LPCSTR lpszAgent,
[in] DWORD dwAccessType,
[in, optional] LPCSTR lpszProxyName,
[in, optional] LPCSTR lpszProxyBypass,
[in] DWORD dwFlags
);
Parameters
| Parameter | Description |
|---|---|
lpszAgent |
A pointer to a null-terminated string that contains the name of the calling application or object. This name is used in protocol requests, such as FTP or HTTP. |
dwAccessType |
The type of access to the Internet. This parameter can be one of the following values:
|
lpszProxyName |
A pointer to a null-terminated string that specifies the name and path of the proxy server to use when |
lpszProxyBypass |
A pointer to a null-terminated string that specifies an optional list of addresses that should be bypassed when using a proxy server. This parameter is only used when |
dwFlags |
Flags that control the behavior of the session. This parameter can be zero or a combination of the following values:
|
Return Value
If the function succeeds, it returns a valid handle to the WinInet service. An application must close this handle by calling the InternetCloseHandle function.
If the function fails, it returns NULL. To get extended error information, call GetLastError.
Remarks
This is the first WinInet function an application must call. It allocates and prepares an HINTERNET handle for subsequent calls.
If dwAccessType is INTERNET_OPEN_TYPE_PRECONFIG, WinInet reads proxy settings from the registry.
If dwAccessType is INTERNET_OPEN_TYPE_PROXY, WinInet uses the proxy server specified in lpszProxyName. If lpszProxyName is NULL and dwAccessType is INTERNET_OPEN_TYPE_PROXY, an error is returned.
If lpszProxyBypass is not NULL, it specifies a list of addresses that should not be routed through the proxy server. The addresses are separated by semicolons (;). Wildcards can be used in host names. For example, "*.example.com;192.168.1.0/24".
The INTERNET_FLAG_ASYNC flag enables asynchronous operations, which means WinInet functions will return immediately without waiting for the operation to complete. The application must then implement a mechanism to receive notifications when the operation is finished.
Note
It is recommended to use the wide-character version of this function, InternetOpenW, to avoid potential issues with character encoding.
Requirements
| Component | Value |
|---|---|
| Minimum supported client | Windows 2000 Professional [desktop apps only] |
| Minimum supported server | Windows 2000 Server [desktop apps only] |
| Header | wininet.h |
| Library | wininet.lib |
| DLL | wininet.dll |