dwErr = InternetErrorDlg
(
GetDesktopWindow(),
hRequest,
ERROR_INTERNET_INCORRECT_PASSWORD,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS |
FLAGS_ERROR_UI_FLAGS_GENERATE_DATA,
NULL
);
but dwErr always returned 0 and never prompt the user to enter in username and
password. Does anyone know why or what is causing this? The calls that I'm
using is as followed:
hInternet = InternetOpen
(
"Test App", // app name
INTERNET_OPEN_TYPE_PROXY,
szProxyServer, // proxy server (i.e.)http://10.21.21.2:8080)
0, // proxy port
0 // flags
);
hConnect = InternetConnect
(
hInternet, // wininet handle,
pszHost, // host
INTERNET_INVALID_PORT_NUMBER, // port
pszUser, // user
NULL, // pass
INTERNET_SERVICE_HTTP, // service
0, // flags
0 // context
);
hRequest = HttpOpenRequest
(
hConnect, // connect handle
"GET", // request method
pszObject, // object name
NULL, // version
NULL, // referrer
NULL, // accept types
INTERNET_FLAG_KEEP_CONNECTION // flags: keep-alive
| INTERNET_FLAG_RELOAD, // flags: bypass cache
0 // context
);
resend:
fRet = HttpSendRequest
(
hRequest, // request handle
"", // header string
0, // header length
NULL, // post data
0 // post length
);
DWORD dwErr;
dwErr = InternetErrorDlg
(
GetDesktopWindow(),
hRequest,
ERROR_INTERNET_INCORRECT_PASSWORD,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS |
FLAGS_ERROR_UI_FLAGS_GENERATE_DATA,
NULL
);
if (dwErr == ERROR_INTERNET_FORCE_RETRY)
goto resend;
HttpQueryInfo
(
hRequest,
HTTP_QUERY_FLAG_NUMBER | HTTP_QUERY_STATUS_CODE,
&dwStatus,
&cbStatus,
NULL
);
// Dump some bytes.
BYTE bBuf[1024];
DWORD cbBuf;
DWORD cbRead;
cbBuf = sizeof(bBuf);
_setmode( _fileno( stdout ), _O_BINARY );
while (InternetReadFile (hRequest, bBuf, cbBuf, &cbRead) && cbRead)
fwrite (bBuf, 1, cbRead, stdout);
If anyone has any ideas as to what I am doing wrong or if there is an
alternative, please let me know.
Thanks in advance,
Ly
I've been trying to do the same thing (see my posts)! I'm not sure I can be of
much help as I have had bad dealings with WinInet to date and still haven't solved
my problem but...
I've tried using 'InterErrorDlg' and I always get a return value of 6 with no
dialog! Try creating a custom dialog to collect the username/password and set them
with the code below. Use it just after your call to 'InternetOpen':
'INTERNET_OPTION_PROXY_USERNAME = 43 'Value from Wininet.h
'INTERNET_OPTION_PROXY_PASSWORD = 44 'Value from Wininet.h
'Snippet from my VB code
InternetSetOption hOpenHandle, INTERNET_OPTION_PROXY_USERNAME, sUsername,
Len(sUsername)
InternetSetOption hOpenHandle, INTERNET_OPTION_PROXY_PASSWORD, sPassword,
Len(sPassword)
If you use 'HttpQueryInfo' after your call to 'HttpSendRequest' then 'dwStatus'
will be 407 if you require proxy authenication or 401 if you require server
authenication.
Sorry can't be of moe help but I hope it works for you.
Cheers,
Jonathan.
resend:
Thanks in advance,
Ly
.