Results 1 to 15 of 15

Thread: ActiveX Download File

  1. #1

    Thread Starter
    Banned
    Join Date
    Oct 2018
    Location
    Philippines
    Posts
    7

    ActiveX Download File

    Hello,

    I was wondering how to download a file through ActiveX and VB6. It's an installer (exe) that is connected to my website. Here is my code so far:
    Code:
    Private Sub Command1_Click()
    DownloadFile "http://website.com/installer.exe", "c:\install.exe"
    It does not work. This has rattled me for the past couple of days. I've tried other methods but none worked.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: ActiveX Download File

    this sort of looks like an attempt to use urldownloadtofile API, try searching on that

    if there is some procedure downloadfile within the project post that code
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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

    Re: ActiveX Download File

    [...]
    Last edited by dz32; Apr 26th, 2019 at 11:14 AM.

  4. #4

    Thread Starter
    Banned
    Join Date
    Oct 2018
    Location
    Philippines
    Posts
    7

    Re: ActiveX Download File

    Thanks. I'm having another issue where the form doesnt show up when testing IE, like nothing pops up, but that is another error. I will try both.

  5. #5

    Thread Starter
    Banned
    Join Date
    Oct 2018
    Location
    Philippines
    Posts
    7

    Re: ActiveX Download File

    Quote Originally Posted by dz32 View Post
    here is a simple vb6 async downloader

    https://github.com/dzzie/pdfstreamdu...AS3_WebInstall

    Code:
    Private Sub Command1_Click()
            ucAsyncDownload1.StartDownload "http://www.as3sorcerer.com/as3sorcerer_setup.exe" ', vbAsyncReadForceUpdate
    End Sub
    if you are trying to host such code in an activex control running in a web browser though you will probably
    run into security sandbox problems.

    Its better to just let the web user download the installer directly.
    Where is the file saved?

  6. #6
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,042

    Re: ActiveX Download File

    [...]
    Last edited by dz32; Apr 26th, 2019 at 11:14 AM.

  7. #7

    Thread Starter
    Banned
    Join Date
    Oct 2018
    Location
    Philippines
    Posts
    7

    Re: ActiveX Download File

    So it would look like this?
    Name:  78b7f95a329a3be13d9573dc67624094.jpg
Views: 351
Size:  15.4 KB

  8. #8
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,042

    Re: ActiveX Download File

    [...]
    Last edited by dz32; Apr 26th, 2019 at 11:13 AM.

  9. #9
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: ActiveX Download File

    if someone can let me know where i can upload a temp zip file, i can upload a simple project that uses a user control
    to download an image & also html. From there you can adjust to suit your needs.
    Original usercontrol was made by Filipe Lage and i have added a couple of extra bits.

  10. #10

    Thread Starter
    Banned
    Join Date
    Oct 2018
    Location
    Philippines
    Posts
    7

    Re: ActiveX Download File

    You could use google drive or mediafire.

  11. #11
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: ActiveX Download File


  12. #12

    Thread Starter
    Banned
    Join Date
    Oct 2018
    Location
    Philippines
    Posts
    7

    Re: ActiveX Download File

    Many thanks

  13. #13

    Thread Starter
    Banned
    Join Date
    Oct 2018
    Location
    Philippines
    Posts
    7

    Re: ActiveX Download File

    When changed to an exe link, it said variable not defined.

  14. #14
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: ActiveX Download File

    Quote Originally Posted by Jeeper View Post
    When changed to an exe link, it said variable not defined.
    what is the link that you are trying to download

  15. #15
    Junior Member
    Join Date
    Dec 2016
    Posts
    22

    Re: ActiveX Download File

    URLDownloadToFile should be sufficient if you consider some basics.

    a) the targetfolder must exist - otherwise the api will fail. (good potential target is the %temp% - folder of the user.
    b) even if the api return success .. some desktop av - scanner can block the file access for a short time. so enum until the file actually exists.
    (kind of Do loop + check if the file exists) - the below sample is highlevel and dont evoid enless loop - its just a sample

    Code:
    Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
    ..
    lRet = URLDownloadToFile(0, sURL, sLocalTargetFile, 0, 0)
    DoEvents
    If lRet = 0 Then
      Do
        If Len(Dir(sLocalFile, 32)) <> 0 Then Exit Do
        DoEvents
      Loop
    End If

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