VB6判断某一个连接是否保存在Cache中下
Public Function GetCacheEntryInfo(ByVal hWnd As Long, ByVal lpszUrl As String) As Boolean
Dim dwEntrySize As Long
Dim lpCacheEntry As INTERNET_CACHE_ENTRY_INFO
Dim dwTemp As Long
Dim lErr As Long
If (GetUrlCacheEntryInfo(lpszUrl, ByVal 0&, dwEntrySize)) = 0 Then
lErr = Err.LastDllError
If (lErr <> ERROR_INSUFFICIENT_BUFFER) Then
’URL没有在Cache中
Err.Raise eeErrorBase + 1, App.EXEName & ".mCacheEntry", WinAPIError(lErr)
GetCacheEntryInfo = False
Exit Function
Else
’URL保存在Cache中
GetCacheEntryInfo = True
End If
End If
End Function
Private Sub Command1_Click()
On Error GoTo ErrorHandler
If (GetCacheEntryInfo(Me.hWnd, Text1.Text)) Then
MsgBox "URL 保存在Cache中.", vbInformation
Else
MsgBox "URL 没有保存在Cache中.", vbInformation
End If
Exit Sub
ErrorHandler:
MsgBox "URL 没有保存在Cache中 [" & Err.Description & "]", vbInformation
End Sub
Private Sub Form_Load()
Form1.CurrentX = 150: Form1.CurrentY = 60
Form1.Print "在Text1中输入URL,按Command1检测"
Text1.Text = ""
Command1.Default = True
End Sub
运行程序,在TextBox中输入URL地址(例如http://member.netease.com/~blackcat),然后点击Command1
按钮,如果URL在Cache中,程序会弹出消息框显示URL 保存在Cache中
Dim dwEntrySize As Long
Dim lpCacheEntry As INTERNET_CACHE_ENTRY_INFO
Dim dwTemp As Long
Dim lErr As Long
If (GetUrlCacheEntryInfo(lpszUrl, ByVal 0&, dwEntrySize)) = 0 Then
lErr = Err.LastDllError
If (lErr <> ERROR_INSUFFICIENT_BUFFER) Then
’URL没有在Cache中
Err.Raise eeErrorBase + 1, App.EXEName & ".mCacheEntry", WinAPIError(lErr)
GetCacheEntryInfo = False
Exit Function
Else
’URL保存在Cache中
GetCacheEntryInfo = True
End If
End If
End Function
Private Sub Command1_Click()
On Error GoTo ErrorHandler
If (GetCacheEntryInfo(Me.hWnd, Text1.Text)) Then
MsgBox "URL 保存在Cache中.", vbInformation
Else
MsgBox "URL 没有保存在Cache中.", vbInformation
End If
Exit Sub
ErrorHandler:
MsgBox "URL 没有保存在Cache中 [" & Err.Description & "]", vbInformation
End Sub
Private Sub Form_Load()
Form1.CurrentX = 150: Form1.CurrentY = 60
Form1.Print "在Text1中输入URL,按Command1检测"
Text1.Text = ""
Command1.Default = True
End Sub
运行程序,在TextBox中输入URL地址(例如http://member.netease.com/~blackcat),然后点击Command1
按钮,如果URL在Cache中,程序会弹出消息框显示URL 保存在Cache中