Code : Tout sélectionner
#include <File.au3>
$path1 = "C:\Program Files\AutoIt3\Include\"
$dest1 = @DesktopDir & "\test\Include\"
$path2 = "C:\Program Files\AutoIt3\Icons\"
$dest2 = @DesktopDir & "\test\Icons\"
$totalsize = DirGetSize($path1) + DirGetSize($path2)
Global $done = 0, $file
Global $hProgressProc = DllCallbackRegister('_ProgressProc', 'dword', 'uint64;uint64;uint64;uint64;dword;dword;ptr;ptr;long_ptr')
ProgressOn('Veuillez patienter', 'Copie en cours...', '', -1, -1, 2)
_DoZeCopy($path1, $dest1)
_DoZeCopy($path2, $dest2)
DllCallbackFree($hProgressProc)
ProgressOff()
;========================================================
Func _DoZeCopy($path, $dest)
If not FileExists($dest) Then DirCreate($dest)
$array = _FileListToArray($path, "*", 1)
For $i = 1 to $array[0]
$file = $array[$i]
_WinAPI_CopyFileEx($path & $file, $dest & $file, 0, DllCallBackGetPtr($hProgressProc))
Sleep(20)
Next
EndFunc
Func _ProgressProc($iTotalFileSize, $iTotalBytesTransferred, $iStreamSize, $iStreamBytesTransferred, $iStreamNumber, $iCallbackReason, $hSourceFile, $hDestinationFile, $iData)
Local $Percent = Round( ($done + $iTotalBytesTransferred) / $totalsize * 100)
If $iTotalBytesTransferred = $iTotalFileSize Then $done += $iTotalFileSize
If $Percent = 100 Then
ProgressSet($Percent, '', 'Complete')
Else
ProgressSet($Percent, $file)
EndIf
EndFunc ;==>_ProgressProc
Func _WinAPI_CopyFileEx($sExistingFile, $sNewFile, $iFlags = 0, $pProgressProc = 0, $pData = 0)
Local $Ret = DllCall('kernel32.dll', 'int', 'CopyFileExW', 'wstr', $sExistingFile, 'wstr', $sNewFile, 'ptr', $pProgressProc, 'long_ptr', $pData, 'ptr', 0, 'dword', $iFlags)
If (@error) Or (Not $Ret[0]) Then
Return SetError(1, 0, 0)
EndIf
Return 1
EndFunc ;==>_WinAPI_CopyFileEx