Results 1 to 6 of 6

Thread: CopyFile API - how to monitor process

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    1
    I am using the copyfile API to move large files (>1 Gb) on a network. The API works but due to network traffic and such, it can take from minutes to hours to complete.
    I am wondering if there is a way of monitoring the copy process so that I can tell how far along the copy is ?

    Thanks,

  2. #2
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    Prague, Czech Republic
    Posts
    350
    Use CopyFileEx, but W9x/ME not supported.
    AllApi sample:
    VB Code:
    1. 'in a form (Form1)
    2. Private Sub Form_Load()
    3.     'KPD-Team 2001
    4.     'URL: [url]http://www.allapi.net/[/url]
    5.     'E-Mail: [email][email protected][/email]
    6.     Dim Ret As Long
    7.     'set the graphics mode to persistent
    8.     Me.AutoRedraw = True
    9.     'print some text
    10.     Me.Print "Click the form to abort the filecopy"
    11.     'show the form
    12.     Me.Show
    13.     'start copying
    14.     Ret = CopyFileEx("c:\verybigfile.ext", "c:\copy.ext", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    15.     'show some text
    16.     Me.Print "Filecopy completed " + IIf(Ret = 0, "(ERROR/ABORTED)", "successfully")
    17. End Sub
    18. Private Sub Form_Click()
    19.     'cancel filecopy
    20.     bCancel = 1
    21. End Sub
    22. 'in a module
    23. Public Const PROGRESS_CANCEL = 1
    24. Public Const PROGRESS_CONTINUE = 0
    25. Public Const PROGRESS_QUIET = 3
    26. Public Const PROGRESS_STOP = 2
    27. Public Const COPY_FILE_FAIL_IF_EXISTS = &H1
    28. Public Const COPY_FILE_RESTARTABLE = &H2
    29. 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
    30. Public bCancel As Long
    31. 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
    32.     'adjust the caption
    33.     Form1.Caption = CStr(Int((TotalBytesTransferred * 10000) / (TotalFileSize * 10000) * 100)) + "% complete..."
    34.     'allow user input
    35.     DoEvents
    36.     'continue filecopy
    37.     CopyProgressRoutine = PROGRESS_CONTINUE
    38. End Function

  3. #3
    New Member
    Join Date
    Aug 2004
    Posts
    2
    Please try SHFileOperation API.
    Auto Debug for Windows
    http://www.autodebug.com/

  4. #4
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    Why do you people continue to respond to posts over 3 years old?!

    Do you think it matters at this point


    ice
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  5. #5
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    Prague, Czech Republic
    Posts
    350
    Yep,
    Of course I don't think Ray-TFR still waits for answer...

    Though it can help users which have the same troubles today or later and are looking for the solution.

    How do you think I've got to 3 years old thread?

    PS: As you see, autodebug suggested using SHFileOperation, which works even under Win95, so I also have something new learned.

  6. #6
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    Well, if you want things users will be able to find you should probably post in the FAQS that is stickied. MAYBE people will look @ the faqs before they post a question or search the forums...
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width