Private Const FO_MOVE = &H1
Private Const FO_COPY = &H2
Private Const FO_DELETE = &H3
Private Const FO_RENAME = &H3
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_SILENT = &H4
Private Const FOF_NOERRORUI = &H400
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End TypePublic Function CopyFile(ByVal sFrom As String, ByVal sTo As String) As Boolean
Dim udtPath As SHFILEOPSTRUCT
udtPath.hwnd = 0
udtPath.wFunc = FO_COPY
udtPath.pFrom = sFrom
udtPath.pTo = sTo
udtPath.fFlags = FOF_NOCONFIRMATION Or FOF_NOERRORUI
End Function
这是反映文件拷贝的进度。
Private Const FO_COPY = &H2
Private Const FO_DELETE = &H3
Private Const FO_RENAME = &H3
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_SILENT = &H4
Private Const FOF_NOERRORUI = &H400
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End TypePublic Function CopyFile(ByVal sFrom As String, ByVal sTo As String) As Boolean
Dim udtPath As SHFILEOPSTRUCT
udtPath.hwnd = 0
udtPath.wFunc = FO_COPY
udtPath.pFrom = sFrom
udtPath.pTo = sTo
udtPath.fFlags = FOF_NOCONFIRMATION Or FOF_NOERRORUI
End Function
这是反映文件拷贝的进度。
在你的窗口上放一个Animation控件,把Visual Studio的Common\Graphics\Videos\filecopy.avi拷到你的程序目录Private Sub Form_Load()
Animation1.Open App.Path & "\filecopy.avi"
End SubPrivate Sub Command1_Click()
Animation1.Play
End SubPrivate Sub Command2_Click()
Animation1.Stop
End Sub是不是很简单?