您现在的位置: 天下网吧 >> 网吧天地 >> 天下码农 >> 编程界 >> 正文

VB.NET编程调用讯雷下载文件

 

本例所有代码

Imports System
Imports System.Text
Public Class frmThunderClass frmThunder
Private _iStartMode As Integer '讯雷任务下载开始模式
Private ThunderEng As New THUNDERAGENTLib.Agent '创建讯雷调用对象
Private Sub frmThunder_Load()Sub frmThunder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnCancel_Click()Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Close()
End Sub
'开始下载任务
Private Sub btnStartDown_Click()Sub btnStartDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartDown.Click
Dim iOnlyFromOrigin, iOriginThreadCount As Integer
iOnlyFromOrigin = IIf(chkOnlyFromOrigin.Checked = True, 1, 0)
iOriginThreadCount = CInt(txtOriginThreadCounts.Text)
If chkDefault.Checked Then
iOriginThreadCount = -1
End If
ThunderEng.AddTask(txtURL.Text, txtSaveAsFileName.Text, txtSaveDir.Text, txtComment.Text, _
txtReferencePage.Text, _iStartMode, iOnlyFromOrigin, iOriginThreadCount)
ThunderEng.CommitTasks()
Timer1.Enabled = True
End Sub


Private Sub radMaual_Click()Sub radMaual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radMaual.Click, radImmediate.Click, radDefault.Click
Dim rad As RadioButton = CType(sender, RadioButton)
_iStartMode = CInt(rad.Tag)
End Sub
'当任务开始时定时查询任务下载信息
Private Sub Timer1_Tick()Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim sFileSize, sDownedSize, sStatus, sFileName, sPercent As String
Try
sStatus = ThunderEng.GetTaskInfo(txtURL.Text, "Status")
sFileSize = ThunderEng.GetTaskInfo(txtURL.Text, "FileSize")
sDownedSize = ThunderEng.GetTaskInfo(txtURL.Text, "CompletedSize")
sFileName = ThunderEng.GetTaskInfo(txtURL.Text, "FileName")
lblDownedSize.Text = String.Format(lblDownedSize.Tag, sDownedSize)
lblFileSize.Text = String.Format(lblFileSize.Tag, sFileSize)
lblTaskStatus.Text = String.Format(lblTaskStatus.Tag, sStatus)
lblFilename.Text = String.Format(lblFilename.Tag, sFileName)
sPercent = ThunderEng.GetTaskInfo(txtURL.Text, "Percent") '获取下载百分比
lblProgress.Text = String.Format(lblProgress.Tag, sPercent.Remove(3, Len(sPercent) - 3))
Catch ex As Exception
End Try
End Sub
Private Sub chkOnlyFromOrigin_CheckedChanged_1()Sub chkOnlyFromOrigin_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkOnlyFromOrigin.CheckedChanged
Panel1.Enabled = chkOnlyFromOrigin.Checked
End Sub
Private Sub GroupBox1_Enter()Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
End Class

欢迎访问最专业的网吧论坛,无盘论坛,网吧经营,网咖管理,网吧专业论坛 https://bbs.txwb.com

关注天下网吧微信/下载天下网吧APP/天下网吧小程序,一起来超精彩

本文来源:博客园 作者:丐帮帮主

相关文章
没有相关文章
声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。若文章侵犯了您的相关权益,请及时与我们联系,我们会及时处理,感谢您对本站的支持!联系邮箱:support@txwb.com,系统开号,技术支持,服务联系QQ:1175525021本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧 网吧天下