📄 auto.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "自动拷贝小工具"
ClientHeight = 5085
ClientLeft = 60
ClientTop = 345
ClientWidth = 5415
LinkTopic = "Form1"
ScaleHeight = 5085
ScaleWidth = 5415
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Text1
Height = 375
Left = 360
TabIndex = 3
Top = 3840
Width = 4575
End
Begin VB.ListBox List1
Height = 2010
Left = 480
TabIndex = 2
Top = 720
Width = 2175
End
Begin VB.CommandButton Command2
Caption = "停止检测"
Height = 495
Left = 3000
TabIndex = 1
Top = 1920
Width = 1815
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 1000
Left = 3720
Top = 2520
End
Begin VB.CommandButton Command1
Caption = "开始检测"
Height = 495
Left = 3000
TabIndex = 0
Top = 1320
Width = 1815
End
Begin VB.Frame Frame1
Caption = "检测操作"
Height = 2895
Left = 240
TabIndex = 4
Top = 120
Width = 4935
Begin VB.Label Label5
Caption = "当前状态: 停止检测"
Height = 255
Left = 2880
TabIndex = 10
Top = 600
Width = 1695
End
Begin VB.Label Label4
Caption = "移动介质列表:"
Height = 255
Left = 240
TabIndex = 9
Top = 360
Width = 1455
End
End
Begin VB.Frame Frame2
Caption = "文件操作"
Height = 1815
Left = 240
TabIndex = 5
Top = 3120
Width = 4935
Begin VB.Label Label3
Height = 255
Left = 1320
TabIndex = 8
Top = 1320
Width = 3015
End
Begin VB.Label Label2
Caption = "系统提示:"
Height = 255
Left = 240
TabIndex = 7
Top = 1320
Width = 975
End
Begin VB.Label Label1
Caption = "请指定要拷贝的文件(包含绝对路径)"
Height = 255
Left = 240
TabIndex = 6
Top = 360
Width = 3135
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim fs, dc, d, i
Private Sub Command1_Click()
Timer1.Enabled = True
List1.Clear
Label5.Caption = "当前状态: 实时检测"
End Sub
Sub GetUDisk()
List1.Clear
Set fs = CreateObject("Scripting.FileSystemObject")
Set dc = fs.Drives
For Each d In dc
If d.DriveType = 1 Then
For i = 0 To List1.ListCount - 1
If List1.List(i) = d.driveletter & ":" Then Exit For
Next
If i = List1.ListCount Then
List1.AddItem d.driveletter & ":"
If List1.ListCount = 1 Then List1.Selected(0) = True
End If
End If
Next
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Label3.Caption = ""
Label5.Caption = "当前状态: 停止检测"
List1.Clear
End Sub
Private Sub Timer1_Timer()
Call GetUDisk
If List1.ListCount = 0 Then
Label3.Caption = "未检测到移动介质!"
Exit Sub
End If
If List1.ListCount > 1 And List1.ListIndex = 0 Then
Label3.Caption = "请指定要拷贝的目标介质!"
Exit Sub
End If
Set fs = CreateObject("Scripting.FileSystemObject")
If Text1.Text = "" Then
Label3.Caption = "未指定要拷贝的文件"
Exit Sub
End If
If fs.fileexists(Text1) Then
If fs.fileexists(List1.List(List1.ListIndex) & "\" & Right(Text1, InStr(StrReverse(Text1), "\") - 1)) Then
Label3.Caption = "指定的文件已拷贝!"
Exit Sub
End If
Label3.Caption = ""
fs.copyfile Text1.Text, List1.List(List1.ListIndex) & "\"
Else
Label3.Caption = "指定的文件不存在!"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -