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

相关文章

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

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

用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:设置或返回串口

VB项目中必需的几点技巧

1.    点击右上角的关闭按钮,要弹出“提示”,是否关闭,但用右键关闭时,不能重复提示 在vb中找到这个事件Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)If MsgBox("是否要退出", vbYesNo + vbDefaultButton2, "提示") = vbNo ThenCancel

redis内存清理和linux系统清理缓存以及redis启动

1清空所有数据库 redis-cli FLUSHALL 2清空所有数据库 redis-cli FLUSHDB 3. 删除指定的缓存键 redis-cli DEL <key> 4. 设置键过期 redis-cli EXPIRE <key> <seconds>例如:redis-cli EXPIRE mykey 60 5.启动redis 这个启动命令要在/usr/loc

在VB.net中,如何把20240906转化成日期格式

==标题== vb.net中,如何把20240906转化成日期格式 ==正文== 在 VB.NET 中,将一个数字字符串(如 "20240906")转换为日期格式,你可以使用 `DateTime.Parse` 或 `DateTime.TryParse` 方法。这些方法可以将符合日期格式的字符串解析为 `DateTime` 对象。以下是如何将 "20240906" 这样的字符串转换为日期格式的示

proe5.0 config.pro 选项清理垃圾关系

proe5.0 config.pro 选项:  cleanup_drawing_dependencies YES_CS_NOT_REQUIRED c leanup_layout_dependencies YES_CS_NOT_REQUIRED 可以清理所有不应该存在的依赖关系 在某些情况下,图纸、布局和模型可能包含对模型的不需要的默认、幽灵、无效、旧的或遗留引用或者垃圾引用,如何删除这些引用?

学习VB语言的步骤和资源

1. 基础知识 1.1 了解VB的基本语法 变量声明**: 使用 `Dim` 关键字。 Dim myVariable As Integer - **条件语句**: 使用 `If...Then...Else`。   If myVariable > 10 ThenMsgBox "Greater than 10"ElseMsgBox "10 or less"End If - **循

宝塔Inode信息使用率100%满了怎么清理?

宝塔面板后台首页除了负载状态、CPU使用率和内存使用率之外,还有一个“/”,即Inode信息,那么,Inode信息使用率满了如何清理?这选项100%的话您的网站可能就无法运行了; 宝塔Inode信息清理方法: 一般主要清理清空面板回收站就好了: 执行命令:rm -rf /www/Recycle_bin/* 不会命令的话直接删除Recycle_bin目录,然后重新新建一个这样的目录就是了,Lin