原帖:http://blog.csdn.net/Modest/archive/2008/06/04/2510834.aspx
Option Explicit<br />Private Declare Function GetUrlCacheEntryInfo Lib "wininet.dll" Alias "GetUrlCacheEntryInfoW" (ByVal szUrlName As Long, ByRef lpCacheEntryInfo As Any, ByRef lpdwCacheEntryInfoBufferSize As Long) As Long<br />Private Declare Function SysAllocString Lib "oleaut32.dll" (ByVal pOlechar As Long) As String<br />Private Type FILETIME<br /> dwLowDateTime As Long<br /> dwHighDateTime As Long<br />End Type<br />Private Type INTE_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 /> dwReserved As Long<br />End Type<br />Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)<br />'(聲明:魏滔序原創,轉貼請註明出處。)<br />Public Function GetCachePath(lpszUrl As String) As String<br /> Dim dwEntrySize As Long<br /> Dim lpCacheEntry As INTE_CACHE_ENTRY_INFO<br /> Dim tarr() As Byte<br /> Call GetUrlCacheEntryInfo(StrPtr(lpszUrl), ByVal 0, dwEntrySize)<br /> If dwEntrySize > 0 Then<br /> ReDim tarr(0 To dwEntrySize)<br /> Call GetUrlCacheEntryInfo(StrPtr(lpszUrl), tarr(0), dwEntrySize)<br /> CopyMem ByVal lpCacheEntry, tarr(0), Len(lpCacheEntry)<br /> GetCachePath = SysAllocString(lpCacheEntry.lpszLocalFileName)<br /> GetCachePath = StrConv(GetCachePath, vbFromUnicode)<br /> End If<br />End Function