I am using URLDownloadToFile to download files from an internet site.
Is there some way to get the date/time the file was uploaded to the site?
"Last-Modified" HTTP header?
i was just tryin to find that info
it does not appear to be a field in the response header...
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
if there is a guy that knows how to do it, it is Gary White (Mr. Php)
try poking around on his site (or even e-mailing him)
http://apptools.com/
I also vote for "last-modified" in the http header.
If you're not using winsockets (which is the preferable way IMO), then function HttpQueryInfo( ..., HTTP_QUERY_LAST_MODIFIED, ... ) might be used. It probably won't work with this ancient URLDownload-stuff, but here is a code snippet which shows the context for usage of HttpQueryInfo():
OnRead proc uses ebx hWnd:HWND, pszUrl:LPSTR
local hInternet:HINTERNET
local hUrl:HINTERNET
local ib:INTERNET_BUFFERS
local estrm:EDITSTREAM
local dwIndex:DWORD
local dwBufLength:DWORD
local szText[128]:byte
...
invoke InternetOpen, CStr("WinINetASM"),INTERNET_OPEN_TYPE_DIRECT,\
NULL, NULL, 0
.if (eax == NULL)
invoke GetLastError
mov g_dwLastError,eax
mov g_pszError,CStr("InternetOpen failed [%X]")
xor eax,eax
ret
.endif
mov hInternet,eax
invoke InternetOpenUrl, hInternet, pszUrl, NULL, NULL,\
INTERNET_FLAG_RELOAD, CONTEXT_ID
.if (eax == NULL)
invoke GetLastError
mov g_dwLastError,eax
invoke InternetCloseHandle, hInternet
mov g_pszError,CStr("InternetOpenUrl failed [%X]")
xor eax,eax
ret
.endif
mov hUrl, eax
mov dwIndex,0
mov dwBufLength, 10000h
invoke HttpQueryInfo, hUrl, HTTP_QUERY_RAW_HEADERS_CRLF,
g_pszHeader, addr dwBufLength, addr dwIndex
invoke ZeroMemory, addr ib, sizeof ib
mov ib.dwStructSize, sizeof INTERNET_BUFFERS
mov eax,g_pszBuffer
mov ib.lpvBuffer, eax
mov ib.dwBufferLength, BUFLENGTH
invoke InternetReadFileEx, hUrl, addr ib, 0, CONTEXT_ID
.if (eax)
invoke Show, hWnd
mov eax,1
.else
invoke GetLastError
mov g_dwLastError,eax
...
did not see that field, Drizz and Jeremy - thanks
i looked and looked, too - lol
Thanks guys, it worked. Here's what I finally ended up with-
.data
urlx db "http://www.physicsxxi.com/CurrentImages/P1AME20090810IC0.png",0
.code
testurl proc
local hUrl,hiopen,hqibuff[16],hqisize,index,contextid
inv InternetOpen,addr ProgName,INTERNET_OPEN_TYPE_DIRECT,0,0,0
or eax,eax
jz testurlerr
mov hiopen, eax
mov contextid,99
invoke InternetOpenUrl,hiopen,addr urlx,0,0,INTERNET_FLAG_RELOAD,addr contextid
or eax,eax
jz testurlerr
mov hUrl,eax
mov index,0
mov hqisize,64
invoke HttpQueryInfo, hUrl, HTTP_QUERY_LAST_MODIFIED,addr hqibuff,addr hqisize, addr index
or eax,eax
jz testurlerr
inv MessageBox,hWin,addr hqibuff,0,0
inv InternetCloseHandle,hUrl
testurlret:
ret
testurlerr:
call GetErrDescriptionf
jmp testurlret
testurl endp
The only thing I don't understand is the last parameter for the InternetOpen api. If I put in INTERNET_FLAG_ASYNC, it fails. If I just put in zero, it works?
You're not making long web requests, right? Then, just leave it as zero. That's really my only understanding of the use for INTERNET_FLAG_ASYNC; I could be wrong.