📄 frmupdate.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form FrmUpDate
Caption = "在线升级"
ClientHeight = 1440
ClientLeft = 60
ClientTop = 345
ClientWidth = 5880
Icon = "FrmUpDate.frx":0000
LinkTopic = "Form1"
ScaleHeight = 1440
ScaleWidth = 5880
StartUpPosition = 2 '屏幕中心
Begin InetCtlsObjects.Inet Inet1
Left = 0
Top = 840
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
End
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 375
Left = 120
TabIndex = 0
Top = 480
Width = 5655
_ExtentX = 9975
_ExtentY = 661
_Version = 393216
Appearance = 1
End
Begin VB.Label lblProgressInfo
Height = 255
Left = 120
TabIndex = 1
Top = 120
Width = 5655
End
End
Attribute VB_Name = "FrmUpDate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private m_lngDocSize As Long
Private Const strURL = "http://upserver4.ys168.com/ys168up/D1/YY.aspx?f=04M49E6E6E4E0D9D5UVN3UN630UR956UWV7UM363UM877D6A01A20A01I5F9G1D9D8D9E1D6E5A24E7E3E1D9E7C2"
'Private Const strURL = "http://www.lynnet.org/Update/人事管理系统Ver2.0.exe"
Private Const FileName = "人事管理系统.exe"
Private Sub Form_Load()
'文件大小值复位
m_lngDocSize = 0
'复位进度条控件
ProgressBar1.Value = 0.001
'显示进度的标签内容设为空
lblProgressInfo.Caption = ""
'定义ITC控件使用的协议为HTTP协议
Inet1.Protocol = icHTTP
'调用Execute方法向Web服务器发送HTTP请求
Inet1.Execute Trim$(strURL), "GET"
lblProgressInfo.Caption = "请等待..."
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Shell App.Path & "\" & FileName, vbNormalFocus
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim binBuffer() As Byte
Dim sngProgerssValue As Single
Dim iBlock As Long
On Error Resume Next
iBlock = 0
Select Case State
Case icResponseCompleted
'打开文件供写入
Open App.Path & "\" & FileName For Binary Access Write As #1
Do '从缓冲区读取数据
DoEvents
binBuffer = Inet1.GetChunk(512, icByteArray)
'strText = strText & strBuffer
iBlock = iBlock + 1
If m_lngDocSize > 0 Then
'获得进度百分比值
sngProgerssValue = Int((iBlock * 512 / m_lngDocSize) * 100)
'更新进度标签显示内容
lblProgressInfo.Caption = "已下载 " & CStr(iBlock * 512) & " 字节 (" & CStr(sngProgerssValue) & "%)"
'用新值更新进度条控件
ProgressBar1.Value = sngProgerssValue
'写入文件
Put #1, , binBuffer()
End If
Loop Until iBlock * 512 >= m_lngDocSize
'关闭文件
Close #1
MsgBox "升级完成", vbOKOnly Or vbInformation, "在线升级"
Case icResponseReceived
If m_lngDocSize = 0 Then
'读取页面文件大小
If Len(Inet1.GetHeader("Content-Length")) > 0 Then
m_lngDocSize = CLng(Inet1.GetHeader("Content-Length"))
If (m_lngDocSize = 0) Then
MsgBox "读取远程数据出错", vbOKOnly Or vbExclamation, "在线升级"
End If
Else
MsgBox "ERROR!", vbOKOnly Or vbExclamation, "在线升级"
End If
End If
Case icError
MsgBox "与主机通信出错", vbOKOnly Or vbExclamation, "升级失败"
Case icResolvingHost
lblProgressInfo.Caption = "正在查找主机..."
Case icHostResolved
lblProgressInfo.Caption = "已经找到主机"
Case icConnecting
lblProgressInfo.Caption = "正在联系主机"
Case icConnected
lblProgressInfo.Caption = "已经连接到主机"
Case icRequesting
lblProgressInfo.Caption = "正在发送请求..."
Case icRequestSent
lblProgressInfo.Caption = "成功发送请求"
Case icReceivingResponse
lblProgressInfo.Caption = "正在接收回应..."
Case icDisconnecting
lblProgressInfo.Caption = "正在断开连接..."
Case icDisconnected
lblProgressInfo.Caption = "已经断开连接"
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -