-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmodDownloadFromURL.bas
More file actions
23 lines (21 loc) · 1.12 KB
/
modDownloadFromURL.bas
File metadata and controls
23 lines (21 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Attribute VB_Name = "modDownloadfromURL"
Option Explicit
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
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
'Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Public Function DownloadFile(sSourceUrl As String, sLocalFile As String) As Boolean
'
' Download the file. BINDF_GETNEWESTVERSION forces
' the API to download from the specified source.
' Passing 0& as dwReserved causes the locally-cached
' copy to be downloaded, if available. If the API
' returns ERROR_SUCCESS (0), DownloadFile returns True.
'
DownloadFile = URLDownloadToFile(0&, sSourceUrl, sLocalFile, BINDF_GETNEWESTVERSION, 0&) = ERROR_SUCCESS
End Function