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 Public Event ErrorDownload(FromPathName As String, ToPathName As String)
Public Event DownloadComplete(FromPathName As String, ToPathName As String) ' функция загрузки
Public Function DownloadFile(FromPathName As String, ToPathName As String) If URLDownloadToFile(0, FromPathName, ToPathName, 0, 0) = 0 Then DownloadFile = True RaiseEvent DownloadComplete(FromPathName, ToPathName) Else DownloadFile = False RaiseEvent ErrorDownload(FromPathName, ToPathName) End If End Function
Private Sub Command1_Click() Call DownloadFile("http://vbnet.ucoz.ru/_ld/0/4_WinDjView-0.3.5.exe", "c:\WinDjView-0.3.5.exe") End Sub
|