分享一段pb2022 自动更新代码
Long ll_FileNum, ll_rtn, ll_loop, ll_lenDec{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) then filedelete(ls_target+"\"+ls_fileslist)
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 ) 都是PB2022自带的控件,没有第三方 能翻译为pb9,或者pb12就好了。 PB12.5可以吗?
PB11能用么 分享pb11.5自用的更新代码
传不了附件吗? 好像是穿不了附件,不过可以贴代码,
现在还有真的有人用pb2022啊,多少钱一个月订购? pb11下几行代码解决不了,只能传pbl
页:
[1]