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
Public
Declare
Function
DeleteUrlCacheEntry
Lib
"wininet"
Alias
"DeleteUrlCacheEntryA"
(
ByVal
lpszUrlName
As
String
)
As
Long
Public
Function
DownloadFile(Url
As
String
, LocalFilename
As
String
)
As
Boolean
Dim
lngRetVal
As
Long
lngRetVal = URLDownloadToFile(0, Url, LocalFilename, 0, 0)
If
lngRetVal = 0
Then
DownloadFile =
True
DeleteUrlCacheEntry Url
End
If
End
Function
使用方法:
DownloadFile
"http://www.baidu.com/img/lm.gif"
, App.Path &
"\lm.gif"