Results 1 to 1 of 1

Thread: [RESOLVED] winhttp and resuming downloads..how to do it?

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2011
    Posts
    191

    Resolved [RESOLVED] winhttp and resuming downloads..how to do it?

    I've looked at how resume works in several examples using winsock..and inet and in each case when you stop the download and try to resume it..it takes forever for the file to get going again..sometimes it even times out..and a few other issues too

    so how do you make winhttp resume downloads?
    the code below is pretty straight forward..i just need to know what needs to be changed to make it support resuming
    Code:
    Public Sub Http_OnResponseStart(ByVal Status As Long, ByVal ContentType As String)
      FileNumber = FreeFile
      mProgress = 0
      mContentLength = CLng(HTTP.GetResponseHeader("Content-Length"))
      lblTotalSize = "Total Size : " & ListView1.ListItems(B).SubItems(4)
      Open FilePathName For Binary Access Write As #FileNumber
    
    End Sub
    
    Public Sub Http_OnResponseDataAvailable(Data() As Byte)
    
      If ExitMe = True Then
        HTTP.Abort
        Close #FileNumber
    
        Exit Sub
    
      End If
    
      If HTTP.Status = 404 Then Exit Sub
      mProgress = mProgress + UBound(Data) + 1
      Percent = Format(mProgress / mContentLength * 100, "#0.00")
    
      Dim PauseTime, Start
    
      PauseTime = 0.01   ' Set duration.
      Start = Timer   ' Set start time.
    
      Do While Timer < Start + PauseTime
        DoEvents   ' Yield to other processes.
      Loop
      ListView1.ListItems(B).SubItems(5) = Percent & " &#37;"
      Put #FileNumber, , Data
    
    End Sub
    
    Private Sub Http_OnResponseFinished()
      ListView1.ListItems(B).SubItems(5) = "Complete"
      Close #FileNumber
    
    End Sub
    Last edited by RRice; Oct 15th, 2011 at 10:52 PM. Reason: typo's

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