How to obtain the file name in Internet cache from a URL (implemented by VB)

Source: Internet
Author: User
Tags filetime internet cache

Reference self-http://blog.csdn.net/cathyeagle/archive/2004/11/05/167900.aspx

 

'Api Declaration
Private type filetime
Dwlowdatetime as long
Dwhighdatetime as long
End type

Private type internet_cache_entry_info
Dwstructsize as long
Lpszsourceurlname as long
Lpszlocalfilename as long
Cacheentrytype as long
Dwusecount as long
Dwhitrate as long
Dwsizelow as long
Dwsizehigh as long
Lastmodifiedtime as filetime
Expiretime as filetime
Lastaccesstime as filetime
Lastsynctime as filetime
Lpheaderinfo as long
Dwheaderinfosize as long
Lpszfileextension as long
'Union {
'Dword dwreserved;
'Dword dwexemptdelta;
'}
Dwreserved as long
End type

Private declare sub movememory lib "kernel32.dll" alias "rtlmovemememory" (byref _
Destination as any, byref source as any, byval length as long)
Private declare function sysallocstring lib "oleaut32.dll" (byval polechar as long) as string

Private declare sub geturlcacheentryinfo lib "wininet. dll" alias _
"Geturlcacheentryinfoa" (byval lpszurlname as string, byref lpcacheentryinfo _
Any, byref lpdwcacheentryinfobuffersize as long)

'Function
Private function getcachepath (lpszurl $) as string

Dim dwentrysize &
Dim lpcacheentry as internet_cache_entry_info
Dim Tarr () as byte

Call geturlcacheentryinfo (lpszurl, byval 0, dwentrysize)
If dwentrysize> 0 then
Redim Tarr (0 to dwentrysize)

Call geturlcacheentryinfo (lpszurl, Tarr (0), dwentrysize)

Movememory lpcacheentry, Tarr (0), Len (lpcacheentry)
Getcachepath = sysallocstring (lpcacheentry. lpszlocalfilename)

Else
'Getcachepath = ""
End if
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.