打印本文 打印本文 关闭窗口 关闭窗口
VB6使用API下载文件
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3256  更新时间:2009/4/23 15:43:32  文章录入:mintao  责任编辑:mintao
0 Then InternetCloseHandle (hOpen) Set myCount = Nothing DownloadFile = lCount End Function Private Sub cmdStart_Click() txtURL.Enabled = False txtFile.Enabled = False cmdStart.Enabled = False cmdStop.Enabled = True DownloadFile txtURL.Text, txtFile.Text cmdStop.Enabled = False cmdStart.Enabled = True txtFile.Enabled = True txtURL.Enabled = True End Sub Private Sub cmdStop_Click() bolStop = True End Sub Private Sub SetText(ByVal txt As TextBox) txt.Text = GetSetting(App.Title, Me.Name, txt.Name) End Sub Private Sub SaveText(ByVal txt As TextBox) SaveSetting App.Title, Me.Name, txt.Name, txt.Text End Sub Private Sub Form_Load() SetText Me.txtFile SetText Me.txtURL End Sub Private Sub Form_Unload(Cancel As Integer) SaveText Me.txtFile SaveText Me.txtURL End Sub Private Function VBStrFormatByteSize(ByVal lngSize As Long) As String Dim strSize As String * 128 Dim strData As String Dim lPos As Long StrFormatByteSize lngSize, strSize, 128 lPos = InStr(1, strSize, Chr$(0)) strData = Left$(strSize, lPos - 1) If lngSize > 1024 Then strData = lngSize & "字节(" & strData & ")" End If VBStrFormatByteSize = strData End Function ''''############################################################################## ''''** ''''** 文件 clsCount.cls 的内容 ''''** ''''############################################################################## VERSION 1.0 CLASS BEGIN MultiUse = -1 ''''True Persistable = 0 ''''NotPersistable DataBindingBehavior = 0 ''''vbNone DataSourceBehavior = 0 ''''vbNone MTSTransactionMode = 0 ''''NotAnMTSObject END Attribute VB_Name = "clsCount" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit ''''****************************************************************************** ''''** ''''** 用于计算速度的类模块 ''''** ''''** 该类模块设定一个计数器,由程序不断的累计数据,并根据所花时间计算数据 ''''** ''''** 编制: 袁永福 ''''** 时间: 2002-4-2 ''''** ''''****************************************************************************** Private Declare Function GetTickCount Lib "kernel32" () As Long Private lngCountStart As Long Private lngCountCurrent As Long Private lngCountLast As Long Private lngSpeed As Long Private lngTickStart As Long Private lngTickCurrent As Long Private lngTickLast As Long ''''Public StopCount As Boolean ''''** 获得计数数据 ************************************************************** ''''** 累计初始值 Public Property Get CountStart() As Long CountStart = lngCountStart End Property ''''** 累计终止值 Public Property Get CountEnd() As Long CountEnd = lngCountCurrent End Property ''''** 累计总的速度 Public Property Get TotalSpeed() As Long If lngTickCurrent = lngTickStart Then TotalSpeed = 0 Else TotalSpeed = (lngCountCurrent - lngCountStart) / ((lngTickCurrent - lngTickStart) / 1000) End If End Property ''''** 累计所花毫秒数 Public Property Get TotalTickCount() As Long TotalTickCount = lngTickCurrent - lngTickStart End Property ''''** 清除所有数据 ************************************************************** Public Sub Clear() lngCountStart = 0 lngCountCurrent = 0 lngCountLast = 0 lngSpeed = 0 lngTickStart = GetTickCount() lngTickCurrent = lngTickStart lngTickLast = lngTickStart ''''StopCount = False End Sub ''''** 设置累计基数 Public Property Let CountStart(ByVal lStart As Long) lngCountStart = lStart lngCountCurrent = lStart End Property ''''** 累加数据 ** Public Sub Count(Optional ByVal lCount As Long

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口