WinInet

Hi All,

I am using WInInet APIs to download a file. For that this is what I am doing -

hInternet = ::InternetOpen(
"AutoUpdater", INTERNET_OPEN_TYPE_PROXY, // Access type
NULL, // Proxy Name
NULL, // Proxy ByPass
INTERNET_FLAG_ASYNC

InternetOpenUrl(hInternet, // Handle to the current Internet session pFileData->GetURI(), //+ "//dataobj.dl_", // Url of the file to be
NULL, // Headers to be
0, // Length
INTERNET_FLAG_RELOAD ,
0 // Context );

pFileData->GetURI() returns a URI.

I always get an error code of 997 that says "Overlapped I/O operation is in progress."

Am I missing something?

Can someone provide some pointers please ?

Raja
[839 byte] By [shekar_raja] at [2007-11-19 9:17:23]
# 1 Re: WinInet
Since you specify INTERNET_FLAG_ASYNC in the InternetOpen function, your call is made asynchronously.

So, when calling InternetOpenUrl(...) it should return immediately with a ERROR_IO_PENDING (997), telling you that everything went ok, but that the call hasn't completed yet.

- petter
wildfrog at 2007-11-9 13:49:40 >
# 2 Re: WinInet
So, Can i make it Synchronous call ?

But no such flags are available !!

Raja
shekar_raja at 2007-11-9 13:50:40 >
# 3 Re: WinInet
I also registered a callback function but ironically it is never called.
shekar_raja at 2007-11-9 13:51:39 >
# 4 Re: WinInet
From MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/internetsetstatuscallback.asp):

Note The callback function specified in the lpfnInternetCallback parameter will not be called on asynchronous operations for the request handle when the dwContext parameter of HttpOpenRequest is set to zero (INTERNET_NO_CALLBACK), or the connection handle when the dwContext handle of InternetConnect is set to zero (INTERNET_NO_CALLBACK).

I had a similar problem, both with HttpSendRequestEx(...) return FALSE (on error 997 and with my callback not being called because I had set the callback on the request handle and had (at first) specified NULL for the dwContext param on my HttpOpenRequest... I blame M$ for this idiocy.

Ignoring the 997 error and setting the dwContext param on BOTH the HttpOpenRequest and the HttpSendRequestEx works.
dukduk at 2007-11-9 13:52:44 >
# 5 Re: WinInet
[ moved thread ]
Marc G at 2007-11-9 13:53:45 >