InternetSetOption Function

The InternetSetOption function sets an Internet option for the current user or the application.

BOOL InternetSetOption( HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength );

Parameters

Parameter Description
hInternet A handle to the Internet object for which the option is to be set. This can be a handle obtained from a call to InternetOpen, InternetConnect, HttpOpenRequest, or any other function that returns an HINTERNET handle.
dwOption The Internet option to be set. This parameter can be one of the values listed in the Internet Option Values section.
lpBuffer A pointer to a buffer that contains the data to be set for the option. The format of this data depends on the value of dwOption.
dwBufferLength The size, in bytes, of the buffer pointed to by lpBuffer.

Return Value

If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error information, call GetLastError.
Note: For some options, the hInternet parameter must be NULL to set the option globally for the application. Other options can be set on specific Internet objects.

Internet Option Values

The following are some of the common values for the dwOption parameter:

INTERNET_OPTION_USERNAME

Sets the username for the current session. lpBuffer should point to a null-terminated string containing the username.

INTERNET_OPTION_PASSWORD

Sets the password for the current session. lpBuffer should point to a null-terminated string containing the password.

INTERNET_OPTION_PER_CONNECTION_OPTION

Configures connection-specific options. lpBuffer should point to an INTERNET_PER_CONNECTION_OPTION structure. This option can only be set on the HINTERNET handle returned by InternetOpen, and hInternet must be NULL.

INTERNET_OPTION_PROXY

Sets the proxy server settings. lpBuffer should point to an INTERNET_PROXY_INFO structure. This option can only be set on the HINTERNET handle returned by InternetOpen, and hInternet must be NULL.

Security Warning: Be cautious when setting sensitive options like usernames and passwords. Ensure you are using secure methods for handling and transmitting credentials.

See Also

← Previous: InternetConnect Next: InternetQueryOption →