參考自 http://blog.csdn.net/cathyeagle/archive/2004/11/05/167900.aspx
'api聲明
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 "RtlMoveMemory" (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 As _
Any, ByRef lpdwCacheEntryInfoBufferSize As Long)
'函數
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