当访问Internet某个站点时,系统首先将远程文件读入到本机Temporary Internet Files文件夹。现在告诉大家一个小技巧可以用VB语言和一个API函数实现判断网页文件是否在IE缓存中。
1.API声明
Private Declare Function GetUrlCacheEn tryInfo Lib ″wininet.dll″ Alias ″GetUrlCacheE ntryInfoA″ ByVal szUrlName As String lpCa cheEntryInfo As Any lpdwCacheEntryInfoBuf ferSize As Long As Long
2.编写函数IsFileInCachesURL
Function IsFileInCacheByVal sURL As String As Boolean Const ERROR_INSUFFICIENT_B UFFER = 122 Dim dwEntrySize As Long If GetUrlCacheEntryInfosURL ByVal 0& dwEntrySize = 0 Then If Err.LastDllError = ERROR_IN SUFFICIENT_BUFFER Then IsFileInCache = True End If End Function
3.举例
MsgBox IsFileInCache″http//www.cpcw.com″
若www.cpcw.com已访问则输出True,否则输出False
以上程序在Win2003+VB6 SP5下测试通过。