VB中如何实现下面的功能

stefc 2005-10-21 10:31:03
清理IE的COOKIE,缓存临时文件,还有清楚历史记录


请写出详细的步骤。

我是菜鸟,刚学不久,希望大家多多关照。
...全文
238 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
linzioo 2005-10-24
  • 打赏
  • 举报
回复
顶,还有没有其他方法,你这个好复杂

通过SHELL的CMD命令就没其他方法了吗?
linzioo 2005-10-23
  • 打赏
  • 举报
回复
顶一个,我也不知道哦
hpjacky 2005-10-23
  • 打赏
  • 举报
回复
顶!
lingll 2005-10-23
  • 打赏
  • 举报
回复
用法,
清除cookie, Call DelCache("cookie:")
清除缓存,Call DelCache("*.*", URLHISTORY_CACHE_ENTRY Or COOKIE_CACHE_ENTRY)
清除所有,Call DelCache("*.*")
还有一个,Call DelCache("visited:"),我不知道怎样描述,大概是访问过的链接吧
lingll 2005-10-23
  • 打赏
  • 举报
回复
网上有源码,我也做了一个,可以 清除cookie,缓存,

新建模块,内容如下
Option Explicit
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSrc As Any, ByVal ByteLen As Long)
'public Declare Function SysAllocString Lib "oleaut32.dll" (ByVal pOlechar As Long) As String
Public Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long

Public Declare Function FindFirstUrlCacheGroup Lib "wininet.dll" ( _
ByVal dwFlags As Long, _
ByVal dwFilter As Long, _
ByRef lpSearchCondition As Long, _
ByVal dwSearchCondition As Long, _
ByRef lpGroupId As Date, _
ByRef lpReserved As Long) As Long

Public Declare Function FindNextUrlCacheGroup Lib "wininet.dll" ( _
ByVal hFind As Long, _
ByRef lpGroupId As Date, _
ByRef lpReserved As Long) As Long

Public Declare Function DeleteUrlCacheGroup Lib "wininet.dll" ( _
ByVal sGroupID As Date, _
ByVal dwFlags As Long, _
ByRef lpReserved As Long) As Long

Public Declare Function FindFirstUrlCacheEntry Lib "wininet.dll" Alias "FindFirstUrlCacheEntryA" ( _
ByVal lpszUrlSearchPattern As String, _
ByRef lpFirstCacheEntryInfo As INTERNET_CACHE_ENTRY_INFO, _
ByRef lpdwFirstCacheEntryInfoBufferSize As Long) As Long

'public Type INTERNET_CACHE_ENTRY_INFO
' dwStructSize As Long
' szRestOfData(1024) As Long
'End Type

Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Public Type INTERNET_CACHE_ENTRY_INFO
dwStructSize As Long
lpszSourceUrlName As Long
lpszLocalFileName As Long
CacheEntryType As Long
dwUseCount As Long
dwHitRate As Long
dwSizeLow As Long
dwSizeHigh As Long
LastModifiedTime As FILETIME
ExpireTime As FILETIME
LastAccessTime As FILETIME
LastSyncTime As FILETIME
lpHeaderInfo As Long
dwHeaderInfoSize As Long
lpszFileExtension As Long
dwReserved As Long
bff(0 To 2048) As Byte
' union {
' DWORD dwReserved;
' DWORD dwExemptDelta;
' }
End Type


Public Const COOKIE_CACHE_ENTRY As Long = &H100000
Public Const URLHISTORY_CACHE_ENTRY As Long = &H200000
Public Const NORMAL_CACHE_ENTRY As Long = &H1
Public Const TRACK_OFFLINE_CACHE_ENTRY As Long = &H10
Public Const TRACK_ONLINE_CACHE_ENTRY As Long = &H20


Public Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" ( _
ByVal lpszUrlName As Long) As Long

Public Declare Function FindNextUrlCacheEntry Lib "wininet.dll" Alias "FindNextUrlCacheEntryA" ( _
ByVal hEnumHandle As Long, _
ByRef lpNextCacheEntryInfo As INTERNET_CACHE_ENTRY_INFO, _
ByRef lpdwNextCacheEntryInfoBufferSize As Long) As Long

Public Const CACHGROUP_SEARCH_ALL = &H0
Public Const ERROR_NO_MORE_FILES = 18
Public Const ERROR_NO_MORE_ITEMS = 259
Public Const CACHEGROUP_FLAG_FLUSHURL_ONDELETE = &H2
Public Const BUFFERSIZE = 2048

Sub main()
Dim tFrm As frmMain
Select Case Command
Case "normal"
Call DelCache("*.*", URLHISTORY_CACHE_ENTRY Or COOKIE_CACHE_ENTRY)
Case "cookie"
Call DelCache("cookie:")
Case "visited"
Call DelCache("visited:")
Case "all"
Call DelCache("*.*")
Case Else
Set tFrm = New frmMain
tFrm.Show
Set tFrm = Nothing
End Select
End Sub


Public Sub DelCache(vUrlSearchPattern As String, Optional vExcluded As Long = 0)
Dim sGroupID As Date
Dim hGroup As Long
Dim hFile As Long
Dim sEntryInfo As INTERNET_CACHE_ENTRY_INFO
Dim iSize As Long

On Error Resume Next


' Delete the groups
hGroup = FindFirstUrlCacheGroup(0, 0, 0, 0, sGroupID, 0)

' To avoid error using it with IE4 as FindFirstUrlCacheGroup is not implemented
If Err.Number <> 453 Then
If (hGroup = 0) And (Err.LastDllError <> 2) Then
'MsgBox "An error occurred enumerating the cache groups" & Err.LastDllError
Debug.Print "An error occurred enumerating the cache groups" & Err.LastDllError
Exit Sub
End If
Else
Err.Clear
End If

If (hGroup <> 0) Then
'we succeeded in finding the first cache group.. enumerate and
'delete
Do
If (0 = DeleteUrlCacheGroup(sGroupID, CACHEGROUP_FLAG_FLUSHURL_ONDELETE, 0)) Then

' To avoid error using it with IE4 as FindFirstUrlCacheGroup is not implemented
If Err.Number <> 453 Then
'MsgBox "Error deleting cache group " & Err.LastDllError
Debug.Print "Error deleting cache group " & Err.LastDllError
Exit Sub
Else
Err.Clear
End If
End If
iSize = BUFFERSIZE
If (0 = FindNextUrlCacheGroup(hGroup, sGroupID, iSize)) And (Err.LastDllError <> 2) Then
'MsgBox "Error finding next url cache group! - " & Err.LastDllError
Debug.Print "Error finding next url cache group! - " & Err.LastDllError
End If
Loop Until Err.LastDllError = 2
End If

' Delete the files
sEntryInfo.dwStructSize = 80
iSize = BUFFERSIZE
hFile = FindFirstUrlCacheEntry(vUrlSearchPattern, sEntryInfo, iSize)
If (hFile = 0) Then
If (Err.LastDllError = ERROR_NO_MORE_ITEMS) Then
'GoTo done
Exit Sub
End If
'MsgBox "ERROR: FindFirstUrlCacheEntry - " & Err.LastDllError
Debug.Print "ERROR: FindFirstUrlCacheEntry - " & Err.LastDllError
Exit Sub
End If

Do
If (sEntryInfo.CacheEntryType And vExcluded) = 0 Then
If (0 = DeleteUrlCacheEntry(sEntryInfo.lpszSourceUrlName)) _
And (Err.LastDllError <> 2) Then
Err.Clear
End If
End If
iSize = BUFFERSIZE
If (0 = FindNextUrlCacheEntry(hFile, sEntryInfo, iSize)) And (Err.LastDllError <> ERROR_NO_MORE_ITEMS) Then
'MsgBox "Error: Unable to find the next cache entry - " & Err.LastDllError
Debug.Print "Error: Unable to find the next cache entry - " & Err.LastDllError
Exit Sub
End If

Loop Until Err.LastDllError = ERROR_NO_MORE_ITEMS

End Sub

Public Function Ptr2StrW(Ptr As Long) As String
Dim sRtn() As Byte

' Check if the pointer is valid
If Ptr <> 0 Then

ReDim sRtn(lstrlen(ByVal Ptr) - 1)

' Copy the string to the byte array
CopyMemory sRtn(0), ByVal Ptr, UBound(sRtn) + 1
Ptr2StrW = sRtn()

End If

End Function

stefc 2005-10-21
  • 打赏
  • 举报
回复
大家帮帮我啊
急用哦
上官云峰 2005-10-21
  • 打赏
  • 举报
回复
对啊,好像正常的效果是不能实现的
上官云峰 2005-10-21
  • 打赏
  • 举报
回复
对啊,好像正常的效果是不能实现的
stefc 2005-10-21
  • 打赏
  • 举报
回复
而且操作系统不同可能就不同哦
stefc 2005-10-21
  • 打赏
  • 举报
回复
没有API函数之类的买?
但是每个用户的临时目录不一定相同啊
weiweiplay 2005-10-21
  • 打赏
  • 举报
回复
IE的COOKIE,缓存临时文件,还有清楚历史记录都是存在缺省目录下的,找到这个目录下的文件,删之
stefc 2005-10-21
  • 打赏
  • 举报
回复
up
stefc 2005-10-21
  • 打赏
  • 举报
回复
大家帮帮我啊

7,765

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧