Automatic credential dialog handling is only supported in WinInet. In WinHTTP you have to provide a way to get the user's username and password yourself and pass it to WinHttpSetCredentials
or similar function. I would check for a return value of ERROR_WINHTTP_LOGIN_FAILURE
from WinHttpGetProxyForUrl
and then ask for the user's credentials. At which point you could try either of the following to pass those credentials to WinHTTP:
- Use
WinHttpSetOption
with WINHTTP_OPTION_USERNAME
and WINHTTP_OPTION_PASSWORD
to set the username and password and recall WinHttpGetProxyForUrl
.
- Or recall
WinHttpGetProxyForUrl
and supply the lpszAutoConfigUrl
parameter with a URL that contains the credentials. (ie http://user:pass@intranet/
).
If you weren't using basic authentication I would suggest looking at fAutoLogonIfChallenged
, but that is of no use to you.