Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The WinHttpSetOption function sets an Internet option.
WINHTTPAPI BOOL WinHttpSetOption(
[in] HINTERNET hInternet,
[in] DWORD dwOption,
[in] LPVOID lpBuffer,
[in] DWORD dwBufferLength
);
[in] hInternet
The HINTERNET handle on which to set data. Be aware that this can be either a Session handle or a Request handle, depending on what option is being set. For more information about how to determine which handle is appropriate to use in setting a particular option, see the Option Flags.
[in] dwOption
An unsigned long integer value that contains the Internet option to set. This can be one of the Option Flags values.
[in] lpBuffer
A pointer to a buffer that contains the option setting.
[in] dwBufferLength
Unsigned long integer value that contains the length of the lpBuffer buffer. The length of the buffer is specified in characters for the following options; for all other options, the length is specified in bytes.
Returns TRUE if successful, or FALSE otherwise. For extended error information, call GetLastError. Among the error codes returned are the following:
Error Code | Description |
---|---|
|
The requested operation cannot be carried out because the handle supplied is not in the correct state. |
|
The type of handle supplied is incorrect for this operation. |
|
An internal error has occurred. |
|
A request to WinHttpQueryOption or WinHttpSetOption specified an invalid option value. |
|
A parameter is not valid.
This value will be returned if WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL is set to a value lower than 15000. |
|
The requested option cannot be set, only queried. |
|
A parameter is not valid.
This value will be returned if WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL is set to a value lower than 15000. |
|
Not enough memory was available to complete the requested operation. (Windows error code) |
Credentials passed to WinHttpSetOption could be unexpectedly sent in plaintext. It is strongly recommended that you use WinHttpQueryAuthSchemes and WinHttpSetCredentials instead of WinHttpSetOption for setting credentials.
GetLastError returns the error ERROR_INVALID_PARAMETER if an option flag is specified that cannot be set.
For more information and code examples that show the use of WinHttpSetOption, see Authentication in WinHTTP.
Requirement | Value |
---|---|
Minimum supported client | Windows XP, Windows 2000 Professional with SP3 [desktop apps only] |
Minimum supported server | Windows Server 2003, Windows 2000 Server with SP3 [desktop apps only] |
Target Platform | Windows |
Header | winhttp.h |
Library | Winhttp.lib |
DLL | Winhttp.dll |
Redistributable | WinHTTP 5.0 and Internet Explorer 5.01 or later on Windows XP and Windows 2000. |
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register today