下载文件显示下载速度问题
以下是位高人写的,小弟想在里面添加 显示每秒下载速度。可是小弟又是菜鸟,只能请各位大哥大姐帮帮忙了。先感谢各位了。。:face (37):
[ 本帖最后由 116154801 于 2009-4-5 00:37 编辑 ] 总大小/下载时间
回复 2# thesnow 的帖子
不会啦。能写个简单点的例子吗》? 小弟不尽感激了 谢谢这位高人啦,自己研究了一下,成功了。。。以下是我写的,希望各位能更完善$URL = "http://vod.bsvip.net/ddvod/user/help/player/divx_for_avi/DivX521XP2K.exe"
$Customer = "DivX521XP2K.exe"
InetGet($URL , $Customer, 1, 1) ;通过HTTP或FTP协议从互联网上下载指定文件.
$InetGetSize = InetGetSize ( $URL ) ;以字节为单位返回存放在互联网上的指定文件的大小.
While @InetGetActive
$s_IniRead = IniRead("C:\Temp\myfile.ini", "速度", "key", "NotFound") ;从某标准配置文件(*.ini)中读取某个数值.
$Bytes = @InetGetBytesRead/1024 ;在 InetGet 下载期间得到的数据大小(字节).
$Bytes_InetGetSize = $InetGetSize/1024 ;以字节为单位返回存放在互联网上的指定文件的大小.
TrayTip("Downloading", "下载速度 = " & $Bytes - $s_IniRead & " 已下载 = " & $Bytes & "总大小 = " & $Bytes_InetGetSize, 10, 16)
$s_IniWrite = IniWrite ( "C:\Temp\myfile.ini", "速度", "key", $Bytes ) ;向某标准配置文件(*.ini)中写入某个数值.
Sleep(250)
Wend
MsgBox(0, "总下载", $Bytes & " 下载速度 = " & $s_IniRead) 这是我再次修正
FileDelete("Temp.ini") ;删除一个或多个文件.
$time1_IniWrite = IniWrite ( "Temp.ini", "time", "time1", @HOUR & @MIN & @SEC ) ;向某标准配置文件(*.ini)中写入某个数值.
$URL = "http://vod.bsvip.net/ddvod/user/help/player/divx_for_avi/DivX521XP2K.exe"
$Customer = "DivX521XP2K.exe"
InetGet($URL , $Customer, 1, 1) ;通过HTTP或FTP协议从互联网上下载指定文件.
$InetGetSize = InetGetSize ( $URL ) ;以字节为单位返回存放在互联网上的指定文件的大小.
While @InetGetActive
$s_IniRead = IniRead("Temp.ini", "速度", "key", "NotFound") ;从某标准配置文件(*.ini)中读取某个数值.
$time1_IniRead = IniRead("Temp.ini", "time", "time1", "NotFound") ;从某标准配置文件(*.ini)中读取某个数值.
$time2_IniRead = IniRead("Temp.ini", "time", "time2", "NotFound") ;从某标准配置文件(*.ini)中读取某个数值.
$time_Down = $time2_IniRead - $time1_IniRead
$Bytes = @InetGetBytesRead/1024 ;在 InetGet 下载期间得到的数据大小(字节).
$Bytes_InetGetSize = Round ($InetGetSize/1024 ,-1) ;以字节为单位返回存放在互联网上的指定文件的大小.Round (四舍五入,-1)
TrayTip("Downloading ", "下载速度 = " & $Bytes - $s_IniRead & " KB " & " 已下载 = " & $Bytes &" KB " & "总大小 = " & $Bytes_InetGetSize& " KB " & " 已用时间 " &$time_Down, 10, 16)
$s_IniWrite = IniWrite ( "Temp.ini", "速度", "key", $Bytes ) ;向某标准配置文件(*.ini)中写入某个数值.
$time2_IniWrite = IniWrite ( "Temp.ini", "time", "time2", @HOUR & @MIN & @SEC ) ;向某标准配置文件(*.ini)中写入某个数值.
$time3_IniWrite = IniWrite ( "Temp.ini", "time", "time3", $time2_IniRead - $time1_IniRead ) ;向某标准配置文件(*.ini)中写入某个数值.
Sleep(1000)
Wend
MsgBox(0, "提示","总下载 = " & $Bytes/1024 & " MB " &" 平均速度 = " & $Bytes_InetGetSize/$time_Down& " KB " & $time_Down& " s ") 呵呵,很带劲,自供自足,可以结帖了 真的不错,谢谢分享 非常的感谢楼主,我也试试 试了下,好像有点问题哦! 能不能将 TrayTip换成窗口模式呢? 真不错~~~~~~~~ 呵呵,很带劲,自供自足,可以结帖了
页:
[1]