Internet技巧两则,第1张

Internet技巧两则,第2张

两项互联网技能

1、判断某个连接是否存储在缓存中

使用微软IE上网时,IE会将你浏览过的网页保存在缓存中,以便你离线浏览。
下面的程序可以确定URL是否在浏览器的缓存中。
首先新建一个VB项目文件,在Form1中添加一个CommandButton控件和一个TextBox控件,然后
在Form1的代码窗口中添加以下代码:

选项显式

Private Const ERROR _ INSUFFICIENT _ BUFFER = 122
Private Const ee ERROR base = 26720

私有类型FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

私有类型INTERNET _ CACHE _ ENTRY _ INFO
dwStructSize As Long
lpszsourceurl name As String
lpszLocalFileName As String
CacheEntryType As String
dwuse count As Long
dwsize low As Long
dwsize high As Long
last modified time As FILETIME
ExpireTIme As FILETIME
last access time As FILETIME

私有声明函数GetUrlCacheEntryInfo Lib " wininet . dll " Alias _
" GetUrlCacheEntryInfoA " _
(ByVal sUrlName为String,_
lpCacheEntryInfo为Any,_
lpdwCacheEntryInfoBufferSize为Long _
)为Long

Private Const FORMAT _ MESSAGE _ ALLOCATE _ BUFFER = & H100
Private Const FORMAT _ MESSAGE _ ARGUMENT _ ARRAY = & h 2000
Private Const FORMAT _ MESSAGE _ FROM _ HMODULE = & H800
Private Const FORMAT _ MESSAGE _ FROM _ STRING = & H400
Private Const FORMAT _ MESSAGE _ FROM _ SYSTEM = & h 1000
Private Const FORMAT _ MESSAGE _ IGNORE _ INSERTS = & h 200
Private

private Declare Function format message Lib " kernel 32 " Alias " format message a " _
(ByVal dw flags为Long,lpSource为Any,ByVal dwMessageId为Long,_
ByVal dwLanguageId为Long,ByVal lpBuffer为String,ByVal nSize为_
Long,Arguments为Long)Long

公共函数winapi error(ByVal lLastDLLError As String
Dim sBuff As String
Dim lCount As Long

&急性;获取错误消息
sbuff = string $ (256,0)
lCount = format message(_
format _ message _ from _ system or format _ message _ ignore _ inserts,_
0,lLastDLLError,0&,sbuff,Len(sBuff),ByVal 0)
If lCount Then
WinAPIError = Left $(sBuff,lCount)
End If
End函数

公共函数GetCacheEntryInfo(ByVal hWnd为Long,ByVal lpszUrl为String)为Boolean
Dim dwEntrySize为Long
Dim lpCacheEntry为INTERNET _ CACHE _ ENTRY _ INFO
Dim dw temp为Long
Dim lErr为Long

如果(GetUrlCacheEntryInfo(lpszul,ByVal 0 & amp,dwEntrySize)) = 0,则
lErr = Err。LastDllError
If(lErr ERROR _ INSUFFICIENT _ BUFFER)Then
& acute;该URL不在缓存中
err.raise eeerrorbase+1,app.exename &”。mcacheentry ",winapi error(lerr)
getcacheentryinfo = false
exit function
else
& acu URL保存在缓存中
getcacheentryinfo = true
end if
end if
end function

private Sub command 1 _ Click()
On Error GoTo Error handler
If(GetCacheEntryInfo(me . hwnd,1。text)),然后
msgbox "URL保存在缓存中。,VB information
else
msgbox " URL未保存在缓存中。,vbInformation
End If

出口接头

ErrorHandler:
MsgBox "URL未保存在缓存中["& err.description &"]",VB information
end sub

private form _ load()
form 1 . currentx = 150:form 1 . currenty = 60
form 1 . print "在Text1中输入URL并按Command1检测"
text 1 . text = " "
command 1。

运行程序,在文本框中输入URL地址(例如,http://member.netease.com/~blackcat),然后单击Command1按钮。如果URL在缓存中,程序将弹出一个消息框,显示URL保存在缓存中。

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » Internet技巧两则

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情