-
Oct 6th, 2018, 05:36 PM
#1
Thread Starter
Banned
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.
-
Oct 6th, 2018, 10:19 PM
#2
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
-
Oct 7th, 2018, 07:31 AM
#3
Re: ActiveX Download File
Last edited by dz32; Apr 26th, 2019 at 11:14 AM.
-
Oct 7th, 2018, 08:52 AM
#4
Thread Starter
Banned
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.
-
Oct 7th, 2018, 11:35 AM
#5
Thread Starter
Banned
Re: ActiveX Download File
Originally Posted by dz32
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?
-
Oct 7th, 2018, 02:01 PM
#6
Re: ActiveX Download File
Last edited by dz32; Apr 26th, 2019 at 11:14 AM.
-
Oct 7th, 2018, 02:57 PM
#7
Thread Starter
Banned
Re: ActiveX Download File
So it would look like this?
-
Oct 8th, 2018, 04:41 AM
#8
Re: ActiveX Download File
Last edited by dz32; Apr 26th, 2019 at 11:13 AM.
-
Oct 8th, 2018, 12:43 PM
#9
Hyperactive Member
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.
-
Oct 8th, 2018, 04:26 PM
#10
Thread Starter
Banned
Re: ActiveX Download File
You could use google drive or mediafire.
-
Oct 9th, 2018, 01:47 AM
#11
Hyperactive Member
Re: ActiveX Download File
-
Oct 12th, 2018, 04:53 PM
#12
Thread Starter
Banned
Re: ActiveX Download File
-
Oct 12th, 2018, 05:06 PM
#13
Thread Starter
Banned
Re: ActiveX Download File
When changed to an exe link, it said variable not defined.
-
Oct 12th, 2018, 06:15 PM
#14
Hyperactive Member
Re: ActiveX Download File
Originally Posted by Jeeper
When changed to an exe link, it said variable not defined.
what is the link that you are trying to download
-
Oct 13th, 2018, 04:56 AM
#15
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|