VB清理临时文件

2024-04-30 09:58
文章标签 清理 vb 临时文件

本文主要是介绍VB清理临时文件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在这里插入图片描述
Option Explicit
Private Declare Function ShellExecute Lib “shell32.dll” Alias “ShellExecuteA” (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function PathFileExists Lib “shlwapi.dll” Alias “PathFileExistsA” (ByVal pszPath As String) As Long
Private Declare Function DeleteFile Lib “kernel32” Alias “DeleteFileA” (ByVal lpFileName As String) As Long
Const RECENT = &H8&
Const PAGETMP = &H20&
Const APPDATA = &H1A
Dim folderName As String, shl As Object
Dim NF As Boolean
Dim Stty As Long

Function RecurseTree(CurrPath As String) As Boolean
Dim sFileName As String, newPath As String, sPath As String, Fs As Object
Static oldPath As String
Text1.Text = “”
NF = True
On Error GoTo ErrLabel
sPath = CurrPath & Chr(92)
sFileName = Dir(sPath, 31)
Set Fs = CreateObject(“Scripting.FileSystemObject”)
Do While sFileName <> “” And NF = True
DoEvents
If sFileName <> Chr(46) And sFileName <> Chr(46) & Chr(46) Then
If GetAttr(sPath & sFileName) And vbDirectory Then
newPath = sPath & sFileName
RecurseTree newPath
sFileName = Dir(sPath, 31)
Else
SetAttr sPath & sFileName, vbNormal
Fs.DeleteFile (sPath & sFileName)
Text1.Text = Text1.Text & sPath & sFileName & vbCrLf
sFileName = Dir
End If
Else
sFileName = Dir
End If
If NF = False Or sFileName = “” Then Text1.Text = Text1.Text & vbCrLf & “-” & IIf(Stty > 0, IIf(Stty > 1, “系统临时文件清理完成!”, “网页浏览记录清理完毕!”), “最近打开的文件清理完毕!”) & “-”: RecurseTree = True: Exit Do
Loop
SetAttr CurrPath, vbNormal
Fs.deletefolder CurrPath
ErrLabel: NF = False
End Function

Private Sub CommandButton1_Click(Index As Integer)
Call Qlxt(Index)
End Sub

Private Sub Fcommand1_Click(Index As Integer)
Select Case Index
Case 0
Call ExitForm
End
Case 1
Call MaximizeForm(Me)
Case 2
Me.WindowState = 1
End Select
End Sub

Private Sub Form_Load()
Me.Caption = “清理系统历史记录”
Text1.Text = “”
Text1.BackColor = vbBlack
Fcommand1(0).Caption = “×”: Fcommand1(1).Caption = “□”: Fcommand1(2).Caption = “▁”:
CommandButton1(0).Caption = “清理最近打开的历史”: CommandButton1(1).Caption = “清理网页历史记录”: CommandButton1(2).Caption = “清理系统临时文件”: CommandButton1(3).Caption = “外挂磁盘自动修复”
Set shl = CreateObject(“shell.application”)
Call ResponseTaskbar(Me)
Call ActivateTheForm(Me)
Form_Resize
Call Qlxt(0)

Fcommand1(0).Move (Me.ScaleWidth - 400), (500 - 300) / 2, 300, 300
Fcommand1(1).Move (Fcommand1(0).Left - Fcommand1(1).Width), (500 - 300) / 2, 300, 300
Fcommand1(2).Move (Fcommand1(1).Left - Fcommand1(2).Width), (500 - 300) / 2, 300, 300
End Sub

Private Sub JBcolor(DX As Object, mStartColor As Long, mCeaseColor As Long)
Dim rSta, gSta, bSta, rEnd, gEnd, bEnd, rInfo, gInfo, bInfo, i
DX.AutoRedraw = True
rSta = mStartColor Mod 256
gSta = mStartColor \ 256 Mod 256
bSta = mStartColor \ 256 \ 256
rEnd = mCeaseColor Mod 256
gEnd = mCeaseColor \ 256 Mod 256
bEnd = mCeaseColor \ 256 \ 256
rInfo = (rEnd - rSta) / 1800
gInfo = (gEnd - gSta) / 1800
bInfo = (bEnd - bSta) / 1800
For i = 0 To 1800
DX.Line (0, i)-(DX.ScaleWidth, i), RGB(rSta + i * rInfo, gSta + i * gInfo, bSta + i * bInfo)
Next
DX.Line (0, 1800)-(DX.ScaleWidth - 8, DX.ScaleHeight - 8), Me.Point(50, 1800), BF
DX.Line (0, 0)-(DX.ScaleWidth - 8, DX.ScaleHeight - 8), RGB(0, 0, 0), B
End Sub

Private Sub Form_Resize()
Me.Cls
Call JBcolor(Me, RGB(83, 83, 83), RGB(200, 200, 200))
Fcommand1(0).Move (Me.ScaleWidth - 400), (500 - 300) / 2, 300, 300
Fcommand1(1).Move (Fcommand1(0).Left - Fcommand1(1).Width), (500 - 300) / 2, 300, 300
Fcommand1(2).Move (Fcommand1(1).Left - Fcommand1(2).Width), (500 - 300) / 2, 300, 300
CommandButton1(0).Move 50, 400
CommandButton1(1).Move (CommandButton1(0).Left + CommandButton1(0).Width), 400
CommandButton1(2).Move (CommandButton1(1).Left + CommandButton1(1).Width), 400
CommandButton1(3).Move (CommandButton1(2).Left + CommandButton1(2).Width), 400
Picture1.Move 50, (CommandButton1(0).Top + CommandButton1(0).Height), Me.ScaleWidth - 100, Me.ScaleHeight - 850
Text1.Move 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
Me.CurrentX = 100: Me.CurrentY = 100
Me.ForeColor = RGB(255, 255, 255)
Me.Print Me.Caption
End Sub

Private Sub Form_DblClick()
If Jpzj(0) = 1 And Jpzj(1) > 50 And Jpzj(1) < 500 Then Call MaximizeForm(Me)
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Jpzj(0) = Button
Jpzj(1) = y
Call Formsize(Me, Button, x, y, , , 1)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MobileForm(Me, Button, x, y)
Call Formsize(Me, Button, x, y)
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Call Formsize(Me, Button, x, y, , , 2)
End Sub

Private Sub Qlxt(Index As Integer)
On Error Resume Next
folderName = shl.NameSpace(RECENT).Self.Path
Select Case Index
Case 0
Call RecurseTree(folderName)
Stty = 0
Case 1
If RecurseTree(folderName) = True Then
folderName = shl.NameSpace(PAGETMP).Self.Path
If RecurseTree(folderName) = True Then
If RecurseTree(Environ(“temp”)) = True Then
End If
End If
DoEvents
End If
Stty = 1
Case 2
Call RecurseTree(folderName)
Stty = 2
Case 3
Call ShellExecute(Me.hwnd, “open”, “chkdsk”, “”, “c:”, 1)
End Select
End Sub
工程包下载地址:https://download.csdn.net/download/ty5858/21829858

这篇关于VB清理临时文件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/948556

相关文章

如何在Mac上彻底删除Edge账户? 手动卸载Edge浏览器并清理残留文件技巧

《如何在Mac上彻底删除Edge账户?手动卸载Edge浏览器并清理残留文件技巧》Mac上的Edge账户里存了不少网站密码和个人信息,结果同事一不小心打开了,简直尴尬到爆炸,想要卸载edge浏览器并清... 如果你遇到 Microsoft Edge 浏览器运行迟缓、频繁崩溃或网页加载异常等问题,可以尝试多种方

使用Python实现Windows系统垃圾清理

《使用Python实现Windows系统垃圾清理》Windows自带的磁盘清理工具功能有限,无法深度清理各类垃圾文件,所以本文为大家介绍了如何使用Python+PyQt5开发一个Windows系统垃圾... 目录一、开发背景与工具概述1.1 为什么需要专业清理工具1.2 工具设计理念二、工具核心功能解析2.

Nacos日志与Raft的数据清理指南

《Nacos日志与Raft的数据清理指南》随着运行时间的增长,Nacos的日志文件(logs/)和Raft持久化数据(data/protocol/raft/)可能会占用大量磁盘空间,影响系统稳定性,本... 目录引言1. Nacos 日志文件(logs/ 目录)清理1.1 日志文件的作用1.2 是否可以删除

如何清理MySQL中的binlog问题

《如何清理MySQL中的binlog问题》:本文主要介绍清理MySQL中的binlog问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目http://www.chinasem.cn录清理mysql中的binlog1.查看binlog过期时间2. 修改binlog过期

python logging模块详解及其日志定时清理方式

《pythonlogging模块详解及其日志定时清理方式》:本文主要介绍pythonlogging模块详解及其日志定时清理方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录python logging模块及日志定时清理1.创建logger对象2.logging.basicCo

Rust中的Drop特性之解读自动化资源清理的魔法

《Rust中的Drop特性之解读自动化资源清理的魔法》Rust通过Drop特性实现了自动清理机制,确保资源在对象超出作用域时自动释放,避免了手动管理资源时可能出现的内存泄漏或双重释放问题,智能指针如B... 目录自动清理机制:Rust 的析构函数提前释放资源:std::mem::drop android的妙

电脑多久清理一次灰尘合? 合理清理电脑上灰尘的科普文

《电脑多久清理一次灰尘合?合理清理电脑上灰尘的科普文》聊起电脑清理灰尘这个话题,我可有不少话要说,你知道吗,电脑就像个勤劳的工人,每天不停地为我们服务,但时间一长,它也会“出汗”——也就是积累灰尘,... 灰尘的堆积几乎是所有电脑用户面临的问题。无论你的房间有多干净,或者你的电脑是否安装了灰尘过滤器,灰尘都

用VB创建开始菜单快捷方式(无需其他DLL)

Option Explicit   Private Sub Command1_Click()   CreateProgManGroup Me, "测试", "test.grp"   CreateProgManItem Me, "d:\ghost.exe", "Ghost"   CreateProgManItem Me, "d:\setupQQ.exe", "QQ"   End

插件:清理maven错误缓存.bat

插件:https://pan.baidu.com/s/1nHIxHoo1C4MvFlW7QbZe5Q?pwd=7zenhttps://pan.baidu.com/s/1nHIxHoo1C4MvFlW7QbZe5Q?pwd=7zen没错误缓存时: 有错误缓存时:

VB和51单片机串口通信讲解(只针对VB部分)

标记:该篇文章全部搬自如下网址:http://www.crystalradio.cn/thread-321839-1-1.html,谢谢啦            里面关于中文接收的部分,大家可以好好学习下,题主也在研究中................... Commport;设置或返回串口号。 SettingS:以字符串的形式设置或返回串口通信参数。 Portopen:设置或返回串口