Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
Private Sub Command1_Click()
DownLoadFile "http://demin.narod.ru/2001/wall/", "wall3.jpg"
End Sub
Public Sub DownLoadFile(sUrl As String, sFile As String)
Dim DL As Long
On Error GoTo errHandler
If sUrl$ = "" Then sUrl$ = strUrl$
If strUrl$ = "" Then strUrl$ = sUrl$
If Left(strUrl$, 4) <> "http" Then strUrl$ = "http://" & strUrl$
If Right$(strUrl$, 1) <> "/" Then strUrl$ = strUrl$ & "/"
If Left$(sFile$, 1) = "/" Then sFile = Mid$(sFile$, 2)
DL& = DoFileDownload(StrConv(strUrl$ & sFile$, vbUnicode))
Exit Sub
errHandler:
Debug.Print "Error Source:", Err.Source
Debug.Print "Error Description:", Err.Description
Debug.Print "Error Number:", Err.Number
MsgBox "An error has occured attempting to start download to " & sUrl & sFile$ & ".", vbApplicationModal + vbCritical + vbDefaultButton1, "Error"
End Sub
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.ru/subscribe/images/question.gif", "c:\1.gif")
End Sub
AlexBlack писал(а):Один из вариантов -- это отношение количества обработанных файлофф, к количеству файлов для обновления ваабще.
Сейчас этот форум просматривают: Google-бот и гости: 73