Braniac
September 10th, 2001, 05:02 AM
How is it done?
I´ve seperated the Sources and Dests with a vbNullChar, however only the first destination is used so all my files end up in the same directory.
Anyone?
Grzzz,
Braniac.
Cimperiali
September 10th, 2001, 07:09 AM
'If you're using winnt,CopyFileEx may be better. Change this to call it several
' times with source and destination changing each time.
'warning: this will not work on win95/98/me
'in a form (Form1)
private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Ret as Long
'set the graphics mode to persistent
me.AutoRedraw = true
'print some text
me.print "Click the form to abort the filecopy"
'show the form
me.Show
'start copying
Ret = CopyFileEx("c:\verybigfile.ext", "c:\copy.ext", AddressOf CopyProgressRoutine, byval 0&, bCancel, COPY_FILE_RESTARTABLE)
'show some text
me.print "Filecopy completed " + IIf(Ret = 0, "(error/ABORTED)", "successfully")
End Sub
private Sub Form_Click()
'cancel filecopy
bCancel = 1
End Sub
'in a module
public Const PROGRESS_CANCEL = 1
public Const PROGRESS_CONTINUE = 0
public Const PROGRESS_QUIET = 3
public Const PROGRESS_STOP = 2
public Const COPY_FILE_FAIL_IF_EXISTS = &H1
public Const COPY_FILE_RESTARTABLE = &H2
public Declare Function CopyFileEx Lib "kernel32.dll" Alias "CopyFileExA" (byval lpExistingFileName as string, byval lpNewFileName as string, byval lpProgressRoutine as Long, lpData as Any, byref pbCancel as Long, byval dwCopyFlags as Long) as Long
public bCancel as Long
public Function CopyProgressRoutine(byval TotalFileSize as Currency, byval TotalBytesTransferred as Currency, byval StreamSize as Currency, byval StreamBytesTransferred as Currency, byval dwStreamNumber as Long, byval dwCallbackReason as Long, byval hSourceFile as Long, byval hDestinationFile as Long, byval lpData as Long) as Long
'adjust the caption
Form1.Caption = CStr(Int((TotalBytesTransferred * 10000) / (TotalFileSize * 10000) * 100)) + "% complete..."
'allow user input
DoEvents
'continue filecopy
CopyProgressRoutine = PROGRESS_CONTINUE
End Function
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Braniac
September 10th, 2001, 08:28 AM
Thanx, it looks very promising and I will try it.
However, I´m developing my app in W98 and the final app will run on NT, so why wouldn't it work on 98 if i may ask?
Grzzz, Braniac.
Cimperiali
September 10th, 2001, 10:42 AM
That Api should not exist (not supported) on win98...
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater