通過URL從Temporary Internet Files得到本地檔案路徑的函數

來源:互聯網
上載者:User

原帖: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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.