CWinHttpRequest.SetOptionmethod
Sets a Microsoft Windows HTTP Services (WinHTTP) option value.
Syntax
FUNCTION SetOption (BYVAL nOption AS WinHttpRequestOption, BYREF dvValue AS DVARIANT) AS HRESULT
Parameters
| Name | Description | |
|---|---|---|
nOption | Value of type WinHttpRequestOption that specifies the option to set. | |
dvValue | DVARIANT. Value to set. |
Return value
Returns S_OK (0) if successful or an error value otherwise.
Description
Sets a Microsoft Windows HTTP Services (WinHTTP) option value.
Remarks
You can set the SecureProtocols option to SecureProtocol_TLS1_2 to enable TLS 1.2 explicitly, ie. pWinHttp.SetOption(WinHttpRequestOption_SecureProtocols, 2048).
Example
#include once "AfxNova/CWinHttpRequest.inc" USING AfxNova
' // Create an instance of the CWinHttp class DIM pWHttp AS CWinHttpRequest ' // Open an HTTP connection to an HTTP resource pWHttp.Open "GET", "http://microsoft.com" ' // Specify the user agent pWHttp.SetOption(WinHttpRequestOption_UserAgentString, "A WinHttpRequest Example Program") ' // Send an HTTP request to the HTTP server pWHttp.Send IF pWHttp.GetLastResult = S_OK THEN ' // Get user agent string. PRINT pWHttp.GetOption(WinHttpRequestOption_UserAgentString) ' // Get URL PRINT pWHttp.GetOption(WinHttpRequestOption_URL) ' // Get URL Code Page. PRINT pWHttp.GetOption(WinHttpRequestOption_URLCodePage) ' // Convert percent symbols to escape sequences. PRINT pWHttp.GetOption(WinHttpRequestOption_EscapePercentInURL) END IF
Reference
- Defined in AfxNova/CWinHttpRequest.inc:554
- Documented in COM/CWinHttpRequest Class.md
- Topic: CWinHttpRequest Class