我有一个应用程序想做成和KV2005一下的在线升级的效果,先把所有的文件下到本地然后关闭应用程序。更新最后重新启动应用程序!!!!
哪位能告诉我思路是怎么的(最好有例子)
谢谢,散分拉。

解决方案 »

  1.   

    http://www.fulgan.com/delphi/autoupdate_unit_for_delphi.htmUsing this unit, you can easily create an auto update feature for your programs. The unit can read the version number out of any win32 PE file and will compare it against the version information located on a simple text file on the web. The grogram doesn't handle the download of the update itself but it can automatically download an additional "Version information" file.The program comes with a fully-functional demo that can be used as well to create the version information text file.
      

  2.   

    用过一般的杀毒软件,都知道,启动程序时,常会问,网上已经有新版本的,是否升级之类的提示,现在越来越多的软件都支持在线升级,你是否也想实现这个功能?本文就如何实现在线升级,讲述一下如何通过HTTP检测是否需要下载升级版本,下载并升级。  实现步骤:   1、网站提供升级信息。
       2、使用HTTP从网站下载升级信息。
       3、确定是否进行升级
       4、升级程序  下面我们定义一下升级信息:   [文件名1]
       datetime=时间
       [文件名2]
       datetime=时间
       存为HTML文件,如定义一个update.htm
       [programe1.exe]
       datetime=2003-07-06
       [programe1.hlp]
       datetime=2003-07-06  这里只是简单的判断一下文件的时间,如果时间比需要升级的文件时间小的,表示要下载新版本升级它。当然要做到十全十美,这是判断是不合理的,这里只作个简单的介绍。  写个fuction,判断是否有新的版本要升级function ExistNewfile&:boolean;
    var i,iFileHandle:integer;
    FileDateTime:TDateTime;
    AppIni:TiniFile;
    g_path:string;
    url:string;
    files:TStrings;
    begin
    result:=false;
    url:=’http://yousoft.hi.com.cn/update.htm/’; //要升级的服务器
    g_path:=ExtractFilePath(application.ExeName); //升级程序的路径
    if copy(g_path,length(g_path),1)<>’\’ then g_path:=g_path+’\’;
    if copy(url,length(url),1)<>’/’ then url:=url+’/’;//下载升级信息文件
    try
    HTTPFiles.InputFileMode := true;
    HTTPFiles.OutputFileMode := FALSE;
    HTTPFiles.ReportLevel := Status_Basic;
    HTTPFiles.Body:=g_path+’update/update.ini’; //下载后保存到程序的update目录下
    HTTPFiles.Get(url);
    except
    result:=false; //取得升级信息出错!,不用再继续
    exit;
    end;
    try
    files:=TStringlist.Create; //有哪些文件?
    AppIni := TIniFile.Create(g_path+’\update\update.ini’);
    AppIni.ReadSections(files);
    for i:=0 to files.Count-1 do
    try
    iFileHandle :=FileOpen(g_path+files,fmShareDenyNone);
    FileDateTime:=FileDateToDateTime(FileGetDate(iFileHandle)); //取得文件时间
    FileClose(iFileHandle);
    //是否要下载文件
    if FileDateTime,’DATETIME’,’1900-1-1’))&NBSP;THEN
    begin
    result:=true;
    break;
    end;
    except
    end;
    finally
    AppIni.free;
    files.Free;
    end;
    end;  取得files后文件下载!httpfiles为TNMHTTPHTTPFiles.InputFileMode := true;
    HTTPFiles.OutputFileMode := FALSE;
    HTTPFiles.ReportLevel := Status_Basic;
    HTTPFiles.Body:=g_path+’update/’+files;
    HTTPFiles.Get(url);  把下载后的文件复制到原程序,并备份出一份for i:=0 to files.Count-1 do //备份文件
    begin
    //备份一份文件出来
    copyfile(pchar(g_path+files),pchar(g_path+files+’.bak’),false);
    end;
    for i:=0 to files.Count-1 do //从update复制新文件
    begin
    copyfile(pchar(g_path+’update\’+files),pchar(g_path+files),false);
    end;  因为采用了TNMHTTP,文件下载的进度并不是很好控制,可以在TNMHTTP的PacketRecvd事件,确定进度
    在线升级的方法就这样简单介绍了,在DELPHI6+WIN2000环境调试通过,这里我没有写出完整的代码,有兴趣可以自己写写。在我的主页我做了演示程序,大家可以看看,网址是:http://yousoft.hi..com.cn
      

  3.   

    我采用的升级模式是这样:
    1、在服务器端设置升级配置文件,我使用的是XML文件,也可以使用ini、txt文件,以自己合适读取为宜。
    <?xml version="1.0" encoding="GB2312"?>
    <update>
    <version>1.0.2.6</version>
    <changes>
    <item>进一步优化网页数据读取速度;</item>
    <item>修正了用户生日不能正确保存的bug;</item>
    <item>退出后自动保存考试时间段。</item>
    </changes>
    <url>http://oem.chinaedu.com/download.asp</url>
    </update>
    2、自动升级:在主程序中设置升级线程,后台下载配置文件。当下载完毕后读取配置文件并与当前版本比较。如果是新版本则弹出提示对话框。
    3、(可选)做自己的升级界面(也可以直接采用HTTP下载)。当软件下载完毕后,检测当前运行的程序,并向用户发出关闭提示。然后升级,然后重新启动程序。其实,有一些组件已经实现了这个技术,例如TAutoUpdate组件,不妨拿来使用或者借鉴。
      

  4.   

    呵呵,我的实现方法跟“jackie168(花好月圓) ”一样。