zbage 发表于 2024-10-25 11:08:28

分享一段pb2022 自动更新代码

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) 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 )

zbage 发表于 2024-10-25 11:11:04

都是PB2022自带的控件,没有第三方

smallanntse 发表于 2024-10-28 10:31:14

能翻译为pb9,或者pb12就好了。

woyaodwn 发表于 2024-11-9 22:55:02

PB12.5可以吗?
页: [1]
查看完整版本: 分享一段pb2022 自动更新代码

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com