Copy, Move oder Delete mit Fortschrittsanzeige
Verfasst: 15.06.2006 14:39
Code: Alles auswählen
Procedure CopyWithProgress(Sources.s(), Destination.s, Function.l = #FO_COPY, Flags.l = #FOF_FILESONLY, ParendID.l = 0)
Protected File.SHFILEOPSTRUCT, *Mem.l, Length.l, Pos.l
*Mem = AllocateMemory(1)
With File
If ParendID = 0
\hwnd = GetForegroundWindow_()
Else
\hwnd = ParendID
EndIf
\wFunc = Function
ForEach Sources()
Length = Len(Sources()) + 1
*Mem = ReAllocateMemory(*Mem, Pos + Length)
PokeS(*Mem + Pos, Sources(), Length)
Pos + Length
Next
\pFrom = *Mem
\pTo = @Destination
\fFlags =Flags
EndWith
If SHFileOperation_(File) = #S_OK
FreeMemory(*Mem)
ProcedureReturn #True
EndIf
FreeMemory(*Mem)
ProcedureReturn #False
EndProcedure
Beispiel:
Code: Alles auswählen
NewList MySources.s()
AddElement(MySources())
MySources() = #PB_Compiler_Home + "PureBasic.exe"
AddElement(MySources())
MySources() = #PB_Compiler_Home + "SmartUpdate.exe"
AddElement(MySources())
MySources() = #PB_Compiler_Home + "Visual Designer.exe"
AddElement(MySources())
MySources() = #PB_Compiler_Home + "Examples\Sources\Billboard.pb"
AddElement(MySources())
MySources() = #PB_Compiler_Home + "Examples\Sources\Camera.pb"
AddElement(MySources())
MySources() = #PB_Compiler_Home + "Examples\Sources\CDAudio.pb"
AddElement(MySources())
MySources() = #PB_Compiler_Home + "Examples\Sources\Cipher.pb"
; hier bitte anpassen, etwas grösseres, sonst sieht man nicht viel
AddElement(MySources())
MySources() = "G:\Installation\CD-Images\Betriebssysteme\Kanotix\KANOTIX-2005-04.iso"
; usw.
CopyWithProgress(MySources(), GetTemporaryDirectory())
Fortschritt auch angezeigt bekommt