Télécharger par HTTP

Télécharger un fichier distant depuis son adresse HTTP

Syntaxe :

Call Download("http://domaine/chemin/fichier.ext", "F:\Mes documents\fichier.ext")

   

'/
'/ A placer dans la partie déclarative
'/
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
Const ERROR_SUCCESS As Long = 0

La fonction : 

Function DownloadFile(sSourceUrl As String, sLocalFile As String) As Boolean
    On Error Resume Next
    Dim lngRetVal As Long
    DownloadFile = URLDownloadToFile(0&, sSourceUrl, sLocalFile, 0&, 0&) = ERROR_SUCCESS
End Function


Dernière modification : 30/09/2010 12:11
Catégorie : Les mémos - Net
Page lue 7293 fois