马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
Long ll_FileNum, ll_rtn, ll_loop, ll_len
Dec{0} ldc_Count, ldc_Length
Blob lb_temp
string ls_currtime
String ls_url, ls_response, ls_Length, ls_data
integer li_rc
//下载
string ls_target, ls_fileslist[]
Is_source = Is_currdir + "\upgrade.zip"
ls_target = Is_currdir + "\"
if FileExists(Is_source) then filedelete(Is_source)
this.enabled = false
cb_close.enabled = false
st_msg.text = "更新中,请等待…"
lhc_Client.ClearRequestHeaders()
ls_url = "http://www.xxx.com/"+Is_zip
ll_rtn = lhc_Client.sendrequest( "HEAD", ls_url )
ls_response = lhc_Client.GetResponseHeaders()
ls_Length = lhc_Client.GetResponseHeader( "Content-Length" )
ldc_Length = Dec ( ls_Length )
If ldc_Length <= 0 Then
st_msg.text = "无效的升级包"
this.enabled = true
cb_close.enabled = true
Return
End If
ll_len = Long ( ldc_Length / 10000 )
hpb_1.maxposition = 10000
hpb_1.position = 0
lhc_Client.autoreaddata = false
ll_rtn = lhc_Client.sendrequest( "GET", ls_url )
ll_loop = 1024 * 16
ll_FileNum = FileOpen(Is_source, StreamMode!, Write!, LockWrite!, Replace!)
Do While ( ll_rtn = 1 )
lb_temp = Blob ( "" )
ll_rtn = lhc_Client.ReadData( lb_temp, ll_loop)
FileWrite(ll_FileNum, lb_temp)
ldc_Count += Len ( lb_temp )
hpb_1.position = Long( ldc_Count/ll_len)
yield()
Loop
FileClose(ll_FileNum)
//解压
ExtractorObject lnv_extractor
Integer li_return, li
lnv_extractor = Create ExtractorObject
lnv_extractor.GetFilesList (Is_source, ls_fileslist[])
for li = 1 to UpperBound(ls_fileslist)
if FileExists(ls_target+"\"+ls_fileslist[li]) then filedelete(ls_target+"\"+ls_fileslist[li])
next
li_return = lnv_extractor.extract (Is_source, ls_target)
setProfileString("config.ini","Setup","UpdateTime",Is_time)
st_msg.text = "系统更新完成,请重新打开主程序!"
filedelete(Is_source)
//messagebox("提示","系统更新完成!"+string(li_return))
cb_close.enabled = true
If IsValid ( lhc_Client ) Then Destroy ( lhc_Client ) |