高手们,谁能用VB编写一个类似迅雷的下载工具啊?
主要能实现下载百分比进度条显示,注释代码,我能提供部分代码,请指教!Private Sub cmd_down_Click()
Dim name As String
name = get_name(Me.Text1.Text)
Open "D:\下载文件" & name For Binary Access Write As #113
Me.Inet.Execute Text1.Text, "get"
End Sub
Private Sub Inet_StateChanged(ByVal State As Integer)
Dim totalbyte As Long
Dim vtdata As Variant
Dim B() As Byte
If State = 12 Then
totalbyte = Inet.GetHeader("content-length")
vtdata = Inet.GetChunk(1024, icByteArray)
Do While LenB(vtdata) > 0
B() = vtdata
Put #113, , B()
DoEvents
vtdata = Inet.GetChunk(1024, icByteArray)
Loop
MsgBox "恭喜你!下载成功!"
End If
End Sub
Public Function get_name(ByVal str As String)
Dim i As Integer
Dim name As String
Dim j As Integer
For i = 1 To Len(str)
If Mid(str, i, 1) = "/" Then
j = i
End If
Next i
name = Right(str, Len(str) - j)
get_name = name
End Function
[解决办法]
如何知道Inet下载文件的进度
原文里面的下载链接貌似失效了,换一个有效链接就行,试过了
代码不负责,貌似无需什么注释了