PB实现自动升级程序
string get_chz,init,dbtype
string ls_AppPath1
int li_ret
string upgrade_file,upgrade_inf,new_ver_no
ver_no="2002091301"
ret_val='failed'
if Handle(GetApplication()) = 0 then
//messagebox("系统","你现在处在开发运行状态!")
ls_apppath="d:\work\drawback"
else
//messagebox("系统","你现在处在执行文件运行状态!")
ls_AppPath = Space (128)
li_ret = GetModuleFileNameA (Handle (GetApplication ()), ls_apppath, 128)
ls_apppath=left(trim(ls_apppath),len(trim(ls_apppath)) -8)
end if
//判断是否有更新版本的程序
integer li_FileNum
//upgrade_inf获取升级文件的版本号
upgrade_inf=profilestring("drawback.ini","upgrade","inf", "")
upgrade_file=upgrade_inf + profilestring("drawback.ini","upgrade","file", "")
if FileExists ( upgrade_file ) then
li_FileNum = FileOpen(upgrade_file,LineMode! ,Read!, Shared! , Replace!)
FileRead ( li_FileNum, new_ver_no )
fileclose(li_FileNum)
if new_ver_no > ver_no then
if messagebox("建议","本程序已经有更新版本("+new_ver_no+"),是否下载并安装?",question!,yesno!)=1 then
if FileExists ( upgrade_inf + "setup.exe" ) then
run( upgrade_inf + "setup.exe")
halt;
else
messagebox("错误","更新程序setup.exe不可得,请检查网络或路径")
end if
end if
end if