请问,如何在网络上更新已经开发的软件,不要到客户那里逐个的更换软件?

解决方案 »

  1.   

    程序的自动升级:
    Detect and Download a new version of (an own) application?
    uses 
      {...,}IniFiles, UrlMon,     type 
      TForm1 = class(TForm) 
        {...} 
      private 
        winsc: TiniFile; 
        old: Integer; 
        vernfo: TIniFile; 
      end; 
       
    implementation {$R *.dfm} function DownloadFile(Source, Dest: string): Boolean; 
      { Function for Downloading the file found on the net } 
    begin 
      try 
        Result := UrlDownloadToFile(nil, PChar(Source), PChar(Dest), 0, nil) = 0; 
      except 
        Result := False; 
      end; 
    end; function GetPathPath: string; 
      { Retrive app path } 
    begin 
      Result := ExtractFilePath(Application.ExeName); 
    end; procedure TForm1.DownLoadNewVersion1Click(Sender: TObject); 
    var 
      apath: string; 
      new: Integer; 
    begin 
      // This is the exact code from my application 
      apath           := GetPathPath; 
      Gauge1.Progress := 0; 
      StatusBar1.SimplePanel := True; 
      StatusBar1.SimpleText := 'Connecting to http://tsoft.home.ro'; 
      Gauge1.Progress := 20; 
      if DownloadFile('http://www.tsoft.home.ro/update.ini', PChar(apath) + '/update.ini') then 
      begin 
        Gauge1.Progress := 50; 
        StatusBAr1.SimplePanel := True; 
        StatusBar1.SimpleText := 'Checking for newer versions...'; 
        vernfo := TiniFile.Create(GetPathPath + '/update.ini'); 
        new    := vernfo.ReadInteger('version', 'wsc', 7); 
        vernfo.Free; 
        if (old = new) then 
        begin 
          StatusBar1.SimplePanel := True; 
          StatusBar1.SimpleText  := 'No new version detected'; 
          Gauge1.Progress        := 100; 
        end 
        else if DownloadFile('http://www.tsoft.home.ro/winsafe.exe', 
          PChar(apath) + '/winsafe.exe') then 
        begin 
          ShowMessage('Update succeseful'); 
          Gauge1.Progress := 100; 
          winsc           := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini')); 
          winsc.WriteInteger('wsc', 'vernfo', new); 
          winsc.Free; 
        end 
        else  
          MessageDlg('A new version has appeard but it requires a second install', 
            mtInformation, [mbOK], 0); 
      end 
      else 
      begin 
        StatusBar1.SimplePanel := True; 
        StatusBar1.SimpleText  := 'Failed to connect probably a internet problem'; 
        Gauge1.Progress        := 0; 
      end; 
    end; procedure TForm1.FormCreate(Sender: TObject); 
    begin 
      //App version 
      winsc := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini')); 
      try 
        old := winsc.ReadInteger('wsc', 'vernfo', 1); 
      finally 
        winsc.Free; 
      end; 
    end; end. {The concept is very simple u download a ini file from your website that contains 
    the version you compare it with the one from your computer and it downloads the 
    file if the versions are Not equal if you find any froblems write me.}
    你的程序只有一个可执行文件。想实现自动升级功能恐怕有点麻烦。必须外挂一个升级程序。在主程序启动之前判断是否有新版本。如果有,就用覆盖拷贝的方式把旧版本的程序覆盖。因为程序本身不能把自己删除然后拷贝。我现在开发的一个东东就是具备自动升级功能。给你讲讲主要的思路吧。
    1:应用程序有一个主框架。这个主框架是不会经常更新的。而且就是这个主框架来实现自动升级功能。
    2:用包的形式调用每一个子模块,也就是*.bpl.这样,我们如果要更新某个模块的功能。就不用将整个应用程序都重新编译了,而只是需要重新编译某一个包文件。然后文件自己有一个时间属性。根据这个属性,就可以判断哪一个是更新的啦。
    3:朱框架有一个上传最新文件的功能。也就是上传*.bpl的功能。编译之后的最新文件通过该功能存储在数据库中。
    4:*.bpl文件是以文件流的方式存储在后台数据库的。同时也存储了这个文件的相关的信息。 比如:名称、创建日期、大小等等。可以在主程序(也就是主框架)启动之后,判断所有的本地文件是否和数据库中的文件信息一致。如果不一致那么下载更新。也可以在调用每一个模块之前判断。这两种方法的利弊。你自己可以分析。
         大概思路就是这些,具体还要你自己在练习中慢慢体会。  GOOD LUCK!
      

  2.   

    谢谢,网虫先生,我现在用的是在服务器上放一个网页,在网页上由软件的版本信息。在软件运行的时候,提取自身的版本信息,然后和网页上的版本上的版本对比。如果自身的版本低,那么就使用FTP方法下载软件,下载完成后,备份正在使用的软件,启动下载的程序,解压覆盖软件中的文件。
    因为开发的时候没有使用包等方法,所以只能更新EXE文件。这种方法有不稳定的因素,请问还有没有更好的方法!
      

  3.   

    我的是在FTP服务器上放了一个文件,这个文件的名字就是软件的最新版本。软件在打开的时候先访问这个文件,如果自身的版本低于这个文件名字的数据,那么下载新的软件。下载后软件自动管理,然后执行下载的SETUP文件,就可以完成自动升级。