As you already told, you can not use NULL
for INTERNET_OPTION_CLIENT_CERT_CONTEXT
option. Although, some option can possessNULL
value, such as INTERNET_OPTION_CONNECT_RETRIES
or INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
, it can't.
You have to use a valid HINTERNET
by using InternetOpen()
or InternetConnect()
.
Below link will guide you for valid HINTERNET
on 'Scope of HINTERNET Handle' section.
Setting and Retrieving Internet Options
And, you have to check hMyStore
and pDesiredCert
values whether those are NULL
, also.
**EDIT : **
You can not get HINTERNET
by using IWebBrowser2
. It just exposes methods and property of WebBrowser
control. So, you have to use InternetConnect()
.
For example, client applications that require a proxy with authentication, probably do not require setting the proxy user name and password every time the application attempts to access an Internet resource. If all requests on a given connection are handled by the same proxy, setting the proxy user name and password on a connection type HINTERNET handle, that is, a handle created by a call to InternetConnect, would allow any calls derived from this HINTERNET handle to use the same proxy user name and password. Setting the proxy user name and password every time an HINTERNET handle is created by HttpOpenRequest would require extra and unnecessary overhead. Be aware that if the application uses a proxy that requires authentication, it should set the proxy credentials on every new connection.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa385384(v=vs.85).aspx
I also wrote some useful reference link about how to use InternetConnect()
.