Download a file with one API call

Download a file with one API call

If you have Internet Explorer 5 or later version, you can use an API call to download a file from the Internet withouth displaying any message box. The following code downloads the demo copy of our VBMaximizer VB6 add-in from our site to the C: directory on your hard disk:

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' Note that this file is 2M, so you might want to try with something simplerDim errcode As LongDim url As StringDim localFileName As Stringurl = ""localFileName = ""errcode = URLDownloadToFile(0, url, localFileName, 0, 0)If errcode = 0 Then    MsgBox "Download ok"Else    MsgBox "Error while downloading"End If


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist