How can I prevent URLDownloadToFile from being cached?

I am using URLDownloadToFile to retrieve a file from a website. Subsequent calls return the original file, not the updated version. I assume it is extracting a cached version.

+3
source share
4 answers

Call DeleteUrlCacheEntry with the same URL just before calling URLDownloadToFile. You will need to install a link to Wininet.lib

+8
source

, . , IBindStatusCallback lpfnCB URLDownloadToFile(). IBindStatusCallback:: GetBindInfo() BINDF_GETNEWESTVERSION BINDF_NOWRITECACHE , grfBINDF. , , , skippe, BINDF_RESYNCHRONIZE.

+4

// Limpa cache do Internet Explorer
procedure DeletaIECache;
var
     lpEntryInfo: PInternetCacheEntryInfo;
     hCacheDir: LongWord;
     dwEntrySize: LongWord;
begin
     dwEntrySize := 0;
     FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize) ;
     GetMem(lpEntryInfo, dwEntrySize) ;
     if dwEntrySize > 0 then lpEntryInfo^.dwStructSize := dwEntrySize;
     hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize) ;
     if hCacheDir <> 0 then
     begin
         repeat
         DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName) ;
         FreeMem(lpEntryInfo, dwEntrySize) ;
         dwEntrySize := 0;
         FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize) ;
         GetMem(lpEntryInfo, dwEntrySize) ;
         if dwEntrySize > 0 then lpEntryInfo^.dwStructSize := dwEntrySize;
         until not FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) ;
     end;
     FreeMem(lpEntryInfo, dwEntrySize) ;
     FindCloseUrlCache(hCacheDir) ;
end;
+1

Source: https://habr.com/ru/post/1696985/


All Articles