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
Private Sub Command1_Click() Dim sourceUrl As String Dim targetFile As String sourceUrl = "http://soft.9zp.com/store.rar" targetFile = "D:\s.rar"
URLDownloadToFile 0&, sourceUrl, targetFile, 0&, 0End Sub
用WININET.DLL吧!功能很强大啊! Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _ (ByVal sAgent As String, ByVal lAccessType As Long, _ ByVal sProxyName As String, ByVal sProxyBypass As String, _ ByVal lFlags As Long) As LongPublic Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _ (ByVal sAgent As String, ByVal lAccessType As Long, _ ByVal sProxyName As String, ByVal sProxyBypass As String, _ ByVal lFlags As Long) As LongPublic Declare Function FTPPutFile Lib "wininet.dll" _ Alias "FtpPutFileA" _ (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _ ByVal lpszRemoteFile As String, ByVal dwFlags As Long, _ ByVal dwContext As Long) As BooleanPublic Declare Function FTPGetFile Lib "wininet.dll" _ Alias "FtpGetFileA" _ (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _ ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, _ ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _ ByVal dwContext As Long) As Boolean
用shdocvw.dll啊 Option Explicit Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As LongPrivate Sub Command1_Click() Dim str As String str = StrConv(Text1.Text, vbUnicode) Call DoFileDownload(str) End SubPrivate Sub Command2_Click() EndEnd SubPrivate Sub Form_Load() Text1.Text = "ftp://192.168.2.39/1.txt" End Sub
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Sub Command1_Click() Dim sourceUrl As String
Dim targetFile As String
sourceUrl = "http://soft.9zp.com/store.rar"
targetFile = "D:\s.rar"
URLDownloadToFile 0&, sourceUrl, targetFile, 0&, 0End Sub
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, _
ByVal sProxyName As String, ByVal sProxyBypass As String, _
ByVal lFlags As Long) As LongPublic Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, _
ByVal sProxyName As String, ByVal sProxyBypass As String, _
ByVal lFlags As Long) As LongPublic Declare Function FTPPutFile Lib "wininet.dll" _
Alias "FtpPutFileA" _
(ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _
ByVal lpszRemoteFile As String, ByVal dwFlags As Long, _
ByVal dwContext As Long) As BooleanPublic Declare Function FTPGetFile Lib "wininet.dll" _
Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, _
ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _
ByVal dwContext As Long) As Boolean
Option Explicit
Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As LongPrivate Sub Command1_Click()
Dim str As String
str = StrConv(Text1.Text, vbUnicode)
Call DoFileDownload(str)
End SubPrivate Sub Command2_Click()
EndEnd SubPrivate Sub Form_Load()
Text1.Text = "ftp://192.168.2.39/1.txt"
End Sub