vb如何清除历史纪录和临时文件

vb如何清除历史纪录和临时文件,第1张

其实就是IE临时目录下文件,把IE临时目录下的文件全删了就行了 这里有一个例子 http://www.downcode.com/downcode/j_13637.shtml 经我测试,上海下载点 可下载,并且可用,里面可以清理IE各种记录,自己看看吧,看不懂也没关系,拿来用就行了

用 GetTempPath 获得系统临时目录,用 GetTempFileName 获取临时文件名。

退出程序时,删除这个临时文件

下面是两个 API 声明:

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long

用VB的FSO *** 作吧

Option Explicit

Private gstrSEP_DIR As String

Sub FPDeleteTree(inPath As String)

'定义临时变量

Dim tmpPath As String, curPath As String

Dim tmpFileName As String

'保存指定路径

curPath = inPath: AddDirSep curPath

'不理目录下文件属性,统统删除。

tmpFileName = Dir(curPath, vbNormal + vbHidden + vbSystem)

Do While Not tmpFileName = " "

SetAttr curPath & tmpFileName, vbNormal

Kill curPath & tmpFileName

tmpFileName = Dir

Loop

'循环删除子目录及其内容

tmpPath = Dir(curPath, vbDirectory)

Do While tmpPath = ". " Or tmpPath = ".. "

tmpPath = Dir

Loop

Do While Not tmpPath = " "

curPath = curPath & tmpPath

AddDirSep curPath

tmpFileName = Dir(curPath, vbNormal + vbHidden + vbSystem)

Do While Not tmpFileName = " "

SetAttr curPath & tmpFileName, vbNormal

Kill curPath & tmpFileName

tmpFileName = Dir

Loop

tmpPath = Dir(curPath, vbDirectory)

Do While tmpPath = ". " Or tmpPath = ".. "

tmpPath = Dir

Loop

If tmpPath = " " Then

RmDir curPath

curPath = inPath

AddDirSep curPath

tmpPath = Dir(curPath, vbDirectory)

Do While tmpPath = ". " Or tmpPath = ".. "

tmpPath = Dir

Loop

End If

Loop

AddDirSep inPath

RmDir inPath

End Sub

'******************************************************************************

' 子程序: AddDirSep

'******************************************************************************

Sub AddDirSep(strPathName As String)

If Right$(RTrim$(strPathName), Len(gstrSEP_DIR)) <> gstrSEP_DIR Then

strPathName = RTrim$(strPathName) & gstrSEP_DIR

End If

End Sub

Private Sub Command1_Click()

gstrSEP_DIR = " "

FPDeleteTree ( "e:www ")

End Sub

网上找的,不知道对你是否有用?

我的目的是为了删除Temporary Internet Files目录下的指定文件,因为全删除后网页的刷新太慢

先getspecialfolder,再kill "*.* "


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11499613.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存