I'm trying to get Wininet to ignore Internet Explorer's "Work Offline" mode, for both HTTP and FTP.
So I'm trying to use InternetSetOption()
with INTERNET_OPTION_IGNORE_OFFLINE
. The documentation says "This is used by InternetQueryOption
and InternetSetOption
with a request handle." However, you can't get a request handle because if IE is in Work Offline mode then InternetConnect()
will always return a null handle. Without a connection handle you can't get a request handle. So I tried using it with an InternetOpen()
handle and a NULL
handle. Both failed with ERROR_INTERNET_INCORRECT_HANDLE_TYPE
.
Is there a way to get this option to work? I found a reference on an MS newsgroup from 2003 that INTERNET_OPEN_TYPE_PRECONFIG
is "broken". 5 years later with IE8 beta 2 and they still haven't fixed it? Or am I doing it wrong.
Edit
I wasn't quite correct. InternetConnect()
always returns null if you are on "Work Offline" mode and using FTP, but it returns a valid handle if you are using Http. However, it still doesn't work even with a request handle.
If I am set to "Work Offline" and I call
BOOL a = TRUE;
::InternetSetOption(hData, INTERNET_OPTION_IGNORE_OFFLINE, &a, sizeof(BOOL));
on the handle from
HINTERNET hData = HttpOpenRequest(hInternet, L"POST", path, NULL, NULL, NULL, flags, 0 );
the InternetSetOption()
call succeeds.
However, the call to HttpSendRequest()
still fails with error code 2 (file not found), same as it does if I don't set the option.
Same thing if I call
::InternetSetOption(hData, INTERNET_OPTION_IGNORE_OFFLINE, 0, 0);