VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Download File from Net

by Kieran Smith (1 Submission)
Category: Internet/HTML
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (11 Votes)

Downloads a file to the host's computer from the internet via api.

Assumes
This is useful for downloading files to the users computer for updates of the current program. This is the code i have used for this purpose.
API Declarations
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

Rate Download File from Net

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
Public Function DownloadFile(URL As String, _
  LocalFilename As String) As Boolean
  Dim lngRetVal As Long
  
  lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
  
  If lngRetVal = 0 Then DownloadFile = True
  
End Function
Private Sub Form_Load()
  DownloadFile "http://www.ksnet.co.uk", "c:\KSNET.htm"
End Sub

Download this snippet    Add to My Saved Code

Download File from Net Comments

No comments have been posted about Download File from Net. Why not be the first to post a comment about Download File from Net.

Post your comment

Subject:
Message:
0/1000 characters