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 Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_RENAME = &H4
Private Sub RenFold(ByVal SPath As String, ByVal DPath As String)
Dim SHF As SHFILEOPSTRUCT
With SHF
.wFunc = FO_RENAME
.pFrom = SPath & Chr(0) '一定要在目錄或名稱後面加上Chr(0)
.pTo = DPath
End With
SHFileOperation SHF
End Sub