您的位置:程序门 -> delphi -> 网络通信/分布式开发



请教:如何判断软件已升级?用ftp下一个txt文件,读一下吗?如何在线升级呢?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请教:如何判断软件已升级?用ftp下一个txt文件,读一下吗?如何在线升级呢?[已结贴,结贴人:morninggood]
发表于:2007-11-22 13:56:39 楼主
是否还有简单方法?谢谢!
发表于:2007-11-22 14:31:001楼 得分:2
发表于:2007-11-22 14:34:522楼 得分:2
应该是有个配置文件的   一半都是xml格式,看那些杀毒软件升级的时候猜的
发表于:2007-11-23 10:02:213楼 得分:0
谢谢。
如果下载了升级的exe,替换当前正在运行的exe,系统会提示文件正在被另一个人或者程序使用。
发表于:2007-11-23 17:19:554楼 得分:0
取该文件的修改日期
发表于:2007-11-24 00:38:015楼 得分:2
关注在线升级问题
发表于:2007-11-25 11:03:586楼 得分:2
这种代码到处有,不想写可以用专门的第三方控件的
发表于:2007-11-26 00:51:007楼 得分:2
用md5效验exe文件   然后对比你最新版本的md5,如果没有升级.
就下载替换.
替换的时候需要你再编写一个辅助程序.
1.下载
2.运行你的辅助程序
3.关闭你的exe程序
4.用辅助程序将原来exe用下载后的替换.
发表于:2007-11-26 09:01:078楼 得分:17
unit   untupdtstat;

interface

uses
    windows,   messages,   sysutils,   variants,   classes,   graphics,   controls,   forms,
    dialogs,   stdctrls,   idbasecomponent,   idcomponent,   idtcpconnection,inifiles,
    idtcpclient,   idftp,shellapi,extctrls,   idftplist,strutils;

type
    tupdtstatform   =   class(tform)
        updtmessage:   tmemo;
        updtftp:   tidftp;
        edit1:   tedit;
        button1:   tbutton;
        timer1:   ttimer;
        label1:   tlabel;
        procedure   button1click(sender:   tobject);
        procedure   timer1timer(sender:   tobject);
        procedure   formcreate(sender:   tobject);

    private
        {   private   declarations   }
    public
        {   public   declarations   }
    end;

var
    updtstatform:   tupdtstatform;


implementation

{$r   *.dfm}
function   getfilenamestr(srcstr:string):string;
var
      i:integer;
begin
    i:=0;
    while   (srcstr[length(srcstr)-i] <> '   ')and   (i <length(srcstr))   do
        inc(i);
    result:=rightstr(srcstr,i);
end;

procedure   tupdtstatform.button1click(sender:   tobject);
begin
    edit1.readonly   :=   true;
    timer1.enabled   :=   true;
end;

procedure   tupdtstatform.timer1timer(sender:   tobject);
var
    tpfilenamestr:string;
    dirstrings:tstrings;
    i:smallint;
    att:tiddiritemtype;
    iniparam   :   tinifile;
    verlocal,verserver:string;
begin
    try
    begin
        updtftp.host   :=   edit1.text;
        updtftp.connect(true);
        updtmessage.lines.add('ftp主机已连接,正在检测程序版本......');
        //updtmessage.lines.add('current   directory   is:"'+updtftp.retrievecurrentdir+'"');
        updtftp.changedir('/lqf');
        //updtmessage.lines.add('current   directory   is:"'+updtftp.retrievecurrentdir+'"');
        iniparam   :=   tinifile.create(getcurrentdir+'\test.ini');
        verlocal   :=   iniparam.readstring('versioninfo','versionno','')   ;
        iniparam.free;
        updtmessage.lines.add('目前本机程序版本:'+verlocal);
        updtftp.get('test.ini','test1.ini',true,false);
        iniparam   :=   tinifile.create(getcurrentdir+'\test1.ini');
        verserver   :=   iniparam.readstring('versioninfo','versionno','')   ;
        iniparam.free;
        deletefile('test1.ini');
        dirstrings   :=   tstringlist.create;
        if   not   (trim(verlocal)=trim(verserver))   then
        begin
            updtmessage.lines.add('服务器有最新版本程序,开始更新......');
            updtftp.list(dirstrings,'',true);
            //updtmessage.lines.add(inttostr(dirstrings.count));
            for   i:=0   to   dirstrings.count-1   do
            begin
                att:=updtftp.directorylisting.items[i].itemtype;
                if   att <> ditfile   then
                    continue;
                tpfilenamestr   :=   getfilenamestr(dirstrings.strings[i]);
                updtmessage.lines.add('下载:'+tpfilenamestr+'......');
                updtftp.get(tpfilenamestr,tpfilenamestr,true,false);
              updtmessage.text   :=   updtmessage.text+'   完成!';
              //updtftp.get(tpfilenamestr,'d:\ftptest\downfiles\'+tpfilenamestr,true,false);
            end;
            updtmessage.lines.add('程序自动更新完成,初始化数据库连接中......');
        end
        else
            updtmessage.lines.add('服务器上的程序没有更新的版本,初始化数据库连接中......');
        //updtftp.get('testomisxndate.exe','testomisxndate.exe',true,false);
        //updtftp.get('1.txt','1.txt',true,false);
        dirstrings.free;
        winEXEC('testomisxndate.exe',sw_show);
        //winEXEC('d:\ftptest\downfiles\testomisxndate.exe',sw_show);
        application.terminate;
    end;
    except   on   e:exception   do
        begin
            timer1.enabled   :=   false;
            //messagedlg('ftp下载更新程序时出错,错误信息:'+e.message,   mterror,   [mbok],   0);
            if   pos('connection   timed   out',e.message) <> 0   then
            begin
                if   messagedlg('指定ftp主机连接不上,“确定”重新输入地址,“否”退出程序',   mtconfirmation,[mbyes,mbno],0)=mrno   then
                    application.terminate;
                edit1.readonly   :=   false;
            end
            else   if   pos('no   route',e.message) <> 0   then
            begin
                messagedlg('本机没有连接网络,请排除故障后重新启动!',   mterror,   [mbok],   0);
                application.terminate;
            end
            else
            begin
                messagedlg('ftp下载更新程序时出错,错误信息:'+e.message,   mterror,   [mbok],   0);
                application.terminate;
            end;
        end;
    end;

end;

procedure   tupdtstatform.formcreate(sender:   tobject);
begin
    edit1.readonly   :=   false;
    edit1.text   :=   '172.18.1.31';
    updtmessage.clear;
    updtmessage.lines.add('程序初始化中......');
end;

end.
发表于:2007-11-26 11:49:489楼 得分:0
感谢各位大侠,我研究一下~
发表于:2007-11-29 21:45:2710楼 得分:3
呵呵,在线升级不过是三步:一、下载配置文件,与本地比较。看需要下载那些文件,二、下载需要的文件,三、更新下载的文件,所有的都是自己控制的,没有那么复杂了。


快速检索

最新资讯
热门点击