How to obtain the file name in Internet cache from a URL

Source: Internet
Author: User
Tags filetime internet cache

Translation from http://blog.csdn.net/CathyEagle/archive/2004/11/05/167900.aspx

 

Private declare function geturlcacheentryinfo lib "wininet. DLL "alias _ <br/>" geturlcacheentryinfow "(byval lpszurlname as long, byval lpcacheentryinfo AS _ <br/> long, byref lpdwcacheentryinfobuffersize as long) as long </P> <p> private const error_insufficient_buffer as long = 122 </P> <p> private declare sub copymemory lib "kernel32.dll" alias "rtlmovemory" (byval destination as long, byval source as long, byval length as long) <br/> private declare function sysallocstring lib "oleaut32.dll" (byval polechar as long) as string </P> <p> private type filetime <br/> dwlowdatetime as long <br/> dwhighdatetime as long <br/> end type </P> <p> private type internet_cache_entry_info <br/> dwstructsize as long <br/> lpszsourceurlname as long <br/> lpszlocalfilename as long <br/> cacheentrytype as long <br/> dwusecount as long <br/> dwhitrate as long <br/> dwsizelow as long <br/> dwsizehigh as long <br/> lastmodifiedtime as filetime <br/> expiretime as filetime <br/> lastaccesstime as filetime <br/> lastsynctime as filetime <br/> lpheaderinfo as long <br/> dwheaderinfosize as long <br/> lpszfileextension as long <br/> 'Union {<br/> 'dword dwreserved; <br/> 'dword dwexemptdelta; <br/> '} <br/> dwreserved as long <br/> end type </P> <p> private function getpathfromurl (lpszurl $) as string </P> <p> dim dwentrysize & </P> <p> dim lpcacheentry as internet_cache_entry_info </P> <p> dim lpcacheentrybyte () as byte </P> <p> dim strtemp (80) as byte <br/> dim dwtemp & </P> <p> 'assume that lpszurl is the image URL. <br/> call geturlcacheentryinfo (strptr (lpszurl), 0, dwentrysize) </P> <p> If err. lastdllerror = error_insufficient_buffer then <br/> redim lpcacheentrybyte (dwentrysize) <br/> debug. print dwentrysize <br/> 'lpcacheentry = (lpinternet_cache_entry_info) New char [dwentrysize]; <br/> else <br/> exit function <br/> end if </P> <p> err. clear </P> <p> call geturlcacheentryinfo (strptr (lpszurl), varptr (lpcacheentrybyte (0), dwentrysize) <br/> debug. print err. lastdllerror <br/> 'if err. lastdllerror = 0 then <br/> '// lpcacheentry-> lpszlocalfilename is the name of the lpszurl file in the cache. <br/> 'Return true; </P> <p> copymemory varptr (lpcacheentry), varptr (lpcacheentrybyte (0), Len (lpcacheentry) </P> <p> getpathfromurl = strconv (sysallocstring (lpcacheentry. lpszlocalfilename), vbfromunicode) <br/> 'end If </P> <p> end Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.