Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Apr : wininet & httpQueryInfo to get file date-time

www.cryer.info
Managed Newsgroup Archive

wininet & httpQueryInfo to get file date-time

Subject:wininet & httpQueryInfo to get file date-time
Posted by:"Joe H" (joedot..@att.net)
Date:21 Apr 2008 16:30:32 -0700

Frustrated once more.

I've been using InternetOpenURL followed by httpQueryInfo to get the
size of a file with no problem and I've followed that with downloading
the file, with no problem. I've tried to use httpqueryinfo and
QUERRY_LAST_MODIFIED to get the date of a file and it returns with the
12150 error -- header not found.

I found an example of using this in one of the Jedi components, and it
used a httpSendrequest(hurl, nil,0,nil,0) before the call. I'm probably
missing something but when I added that and traced through the code it
worked and the following query for lastmodified was successful.
However, when I try to run the program it hangs on that httpsendrequest
line for maybe 3 or 4 minutes before finally succeeding the same way.

I finally read about httpOpenRequest and that a call to that instead of
the InternetOpenURL should preceed the call to httpqueryInfo, but I
can't get it to give me anything but nil back and an error 12018 is the
last error code - ERROR_INTERNET_INCORRECT_HANDLE_TYPE. That really
confuses me. I was using the same hsession handle that works properly
with InternetOpenURL.

I've had a hell of a time figuring out what to put in the content-type
field and it's structure. After getting the correct link from ms
online, I think it's supposed to be 'octet-stream' and I've tried that
every way I can think of and can't get it to work. Since it's supposed
to be a long pointer to an array of pchars, I tried:
  Content: array[0..1] of pchar = ('octet-stream','');

and then passing @content to the field. Compiler accepts this but still
doesn't work. I'm not sure that has anything to do with the problem.

I have now tried:
  internetOpen to get hsession,
  InternetConnect to get hconnect,
  InternetOpenRequest to hrequest

These all yield valid handles. Then I've tried
  InternetQueryInfo(hrequest, ...QUERY_LAST_MODIFIED, ...) and it fails
with 12150.

I've tried,
  InternetSendRequest(hConnect, nil, 0,nil,0) and that takes a moment
or two but succeeds.

then I try the InternetQueryInfo and it again fails with 12150.

If someone knows how this is supposed to work, I'd sure appreciate
knowing about it -- or even a reference that is actually usable. I've
searched the groups and google and not found anything but someone
else's question. Surely this can't be this complicated. I've probably
been at it for too long.

--

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive