请问不用控件的话,在VB里如何实现文件下载?

Kinson 2003-10-19 10:47:00
我希望不用更改Project->Component选项,可以更改Project->Reference选项,Internet transfer control和Winsock control都要添加component
...全文
31 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
sharp22 2003-10-23
  • 打赏
  • 举报
回复
用shdocvw.dll啊
Option Explicit
Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long

Private Sub Command1_Click()
Dim str As String
str = StrConv(Text1.Text, vbUnicode)
Call DoFileDownload(str)
End Sub

Private Sub Command2_Click()
End

End Sub

Private Sub Form_Load()
Text1.Text = "ftp://192.168.2.39/1.txt"
End Sub
intersun 2003-10-22
  • 打赏
  • 举报
回复
同意用WinINET,以API方式调用。
aha99 2003-10-22
  • 打赏
  • 举报
回复
学习
imur 2003-10-21
  • 打赏
  • 举报
回复
学习!
FUNDGIRL 2003-10-21
  • 打赏
  • 举报
回复
用SOCKT API来下载.

其实也不算很难的.外国佬的网站上有一些封装好了的SOCKT模块.你在这些模块的基础上完成HTTP或FTP协议.
hhjjhjhj 2003-10-20
  • 打赏
  • 举报
回复
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&, 0

End Sub
Kinson 2003-10-20
  • 打赏
  • 举报
回复
我希望下载并保存,好像ShellExecute 只是打开,没有保存吧
prun 2003-10-20
  • 打赏
  • 举报
回复
用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 Long

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 Long

Public 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 Boolean

Public 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
Kinson 2003-10-19
  • 打赏
  • 举报
回复
如果project类型是ActiveX DLL可以用ShellExecute吗?用ShellExecute可以自己指定文件存储路径和文件名吗?

能不能给出URLDownloadToFile的例子?
hhjjhjhj 2003-10-19
  • 打赏
  • 举报
回复
用API
URLDownloadToFile
kmzs 2003-10-19
  • 打赏
  • 举报
回复
本来想说用WebBrowser也可以,现在看来只有用shell来下载了,不用控件,Call ShellExecute(Me.hwnd, "open", "http://as.onlinedown.net/down/MyEBook3.rar", vbNullString, vbNullString, &H0)就行了

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧