wrote :: 2006.01.17
Public 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
Ret = URLDownloadToFile(0, DownloadFile, SaveFileName, 0, 0)
Sub Sample()
GetImageFile "http://www.officetanaka.net/sample.jpg", "C:\sample.jpg"
End Sub
Sub GetImageFile(ImgName As String, SaveName As String)
Dim SaveFileName As String, DownloadFile As String, Ret As Long
If ImgName = "" Then Exit Sub
SaveFileName = SaveName
DownloadFile = ImgName
Ret = URLDownloadToFile(0, DownloadFile, SaveFileName, 0, 0)
If Ret = 0 Then
MsgBox "ダウンロードできました"
Else
MsgBox "エラーが発生しました"
End If
End Sub
