cDownload on Vista (vbRichClient5)-VBForums
Results 1 to 4 of 4

Thread: cDownload on Vista (vbRichClient5)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    223

    cDownload on Vista (vbRichClient5)

    Hello,
    I want to download a file (History.txt) from my github and process it to let the user know if an update is available.
    I use this code (taken form some Olaf's example):


    Code:
        Dim Downloads As cDownloads, D As cDownload
     
        URL = "https://miorsoft.github.io/Site/PhotoModularFX/History.txt"
    
        Set Downloads = New_c.Downloads
    
        Set D = Downloads.Download(URL)
      
        D.WaitForCompletion 5     '3 '<- 3 seconds timeout, until we cancel the http-Request
    
        If D.DownloadCompleted And D.GetContentLen > 0 Then
    
            'If MainFSO.FolderExists(APP.Path & "\Update") = False Then
            'MainFSO.CreateDirectory (APP.Path & "\Update")
            'End If
    
    
            If MainFSO.FileExists(APP.Path & "\Update") Then MainFSO.DeleteFile APP.Path & "\Update"
    
            D.SaveContentBytesToFile APP.Path & "\Update"
    
            F = MainFSO.ReadTextContent(APP.Path & "\Update")
            ...
            'ELABORATE "F"  and let user kbow about updates
            ...
        Else
            MsgBox "TimeOut  " & D.DownloadErrorStatusString
    
        End If
    In Windows7(32) it works,
    but in WindowsVista(32) it do Not work

    D.DownloadErrorStatusString is "Resource Not Found"

    "WaitForCompletion" seems to be skipped. Since in IDE it's executed instantly.

    Maybe it's not about Windows Operative System, but about the type of Internet connection .... I do not know.
    * PhotoModularFX project forum
    * Check out my Photo/Video to cartoon and Other projects
    * for my PSC Source Codes look here

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,325

    Re: cDownload on Vista (vbRichClient5)

    There is an issue with modern SSL-certificates, which can cause problems on older machines
    (running XP or Vista) because they don't have the matching Crypto-extensions (which Systems > Vista usually have).

    Normally (on XP but also on Vista) there were System-Updates (as e.g. latest IE8 for XP or IE9 for Vista, but also Crypto-related ones),
    which install newer Crypto-libs on the OS.

    E.g. on an XP-VM which I tried to keep up-to-date (until support ran out), I don't get your Error.
    (don't have a VISTA-VM here to check).

    But on a quite old (non-updated) XP-VM which did not have IE8 installed - and no patches applied, I was able to reproduce the problem...

    And even when trying to hand over an URL which does not specify the secure protocol, but only "http://" instead,
    it will often not help, because many sites enforce (over a redirect-response) to reload with https instead.

    Here is the (slightly changed) code, which I've ran on that failing XP-machine (using cDownloads WithEvents, to get some more info):
    Code:
    Option Explicit
    
    Private WithEvents Downloads As cDownloads
    
    Private Sub Downloads_DownloadProgress(DownloadObj As vbRichClient5.cDownload, ByVal Percent As Single, ByVal StatusCode As Long, StatusDescription As String, StatusValue As String)
      Debug.Print StatusCode, StatusDescription, StatusValue
    End Sub
    
    Private Sub Form_Load()
      Set Downloads = New_c.Downloads
      MsgBox DownloadHistory
    End Sub
    
    Private Function DownloadHistory() As String
      Const URL = "http://miorsoft.github.io/Site/PhotoModularFX/History.txt"
      Dim D As cDownload
      Set D = Downloads.Download(URL)
    
      If Not D.WaitForCompletion(5) Then ' timeout-seconds, until we cancel the http-Request
         DownloadHistory = "TimeOut: " & D.DownloadErrorStatusString
         Exit Function
      End If
      
      If D.DownloadErrorStatus = 0 And D.GetContentLen > 0 Then
         DownloadHistory = StrConv(D.GetContentData, vbUnicode)
      Else
         DownloadHistory = "Error: " & D.DownloadErrorStatusString
      End If
    End Function
    Running the above on the failing XP-machine in question did print out:
    Code:
     1            Finding resource            miorsoft.github.io
     2            Connecting    151.101.113.147
     11           Sending request             
     3            Redirecting   https://miorsoft.github.io/Site/PhotoModularFX/History.txt
     2            Connecting    151.101.113.147
     2            Connecting    151.101.113.147
    What you could try on your VISTA-machine is either:
    - to update to a recent IE (not sure, whether there is somehing higher avail. for Vista than IE9) and to get "as many Updates as are still available"
    - or to use the WInHttp-5.1 Object with the SSL-Error-Ignore Option (see Code below)

    Code:
    Private Function DownloadHistory2() As String
      Const URL = "https://miorsoft.github.io/Site/PhotoModularFX/History.txt"
      Dim http As New WinHttp.WinHttpRequest
          http.Open "GET", URL, True
          http.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_Ignore_All
          http.Option(WinHttpRequestOption_SecureProtocols) = &HA8
          http.Send
       If Not http.WaitForResponse(5) Then ' timeout-seconds, until we cancel the http-Request
         DownloadHistory2 = "TimeOut: " & http.StatusText
         Exit Function
       End If
      
       If http.Status = 200 Then
         DownloadHistory2 = StrConv(http.ResponseBody, vbUnicode)
       Else
         DownloadHistory2 = "Error: " & http.StatusText
       End If
    End Function
    The MS-WinHttp-Object is the better choice for your case anyways, because it "guarantees no re-usage of cached responses".
    (it is always trying to do a real server-roundtrip, retrieving fresh content - which I assume is, what you want).

    The RC5-cDownload-Object is using the Systems URL-Cache - and should only be used for Downloads of relative static content (as e.g. Image-Resources or something).

    HTH

    Olaf

  3. #3
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,684

    Re: cDownload on Vista (vbRichClient5)

    trying to redo my XP VM, and slipstream all the latest available updates (since 2014) is a pain. There's also a registry hack marking your OS as an embedded POS system, to get the last security updates until 2019. If anyone has any tips let me know.
    I'm almost ready to ditch supporting this OS.
    Imagine what it would be like to set breakpoints in, or step through subclassing code;
    and then being able to hit stop/end/debug or continue, without crashing the IDE.

    VB6.tlb | Bulletproof Subclassing in the IDE (no thunks/assembly/DEP issues)

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    223

    Re: cDownload on Vista (vbRichClient5)

    Thanks!
    * PhotoModularFX project forum
    * Check out my Photo/Video to cartoon and Other projects
    * for my PSC Source Codes look here

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.