我自己做的一套仓储管理系统,在一个小局域网内共享,数据库+delphi客户端连接,现在想实现客户端的更新,因为有时会对软件做一点变动。如何能实现,最好有实例的

解决方案 »

  1.   

    我们的方式:
    在服务器上建一个共享文件夹,如:\\server\update
    将主程序(WMS.exe)放到上面。
    再写一个小程序(update.exe),功能就是将服务器上的主程序和本地的程序进行比较(比较文件时间),如不同则将服务器上的文件复制过来;如相同,则不复制。最后,再执行主程序(WMS.exe)
    每次,用户就是执行这个小程序(update.exe),更新完成后,会自动运行这个主程序了。
      

  2.   

    这是我自己摸索使用的方法:
    数据库增加一个版本表,版本表的字段有【版本】、【数据包】
    主程序(Main.exe)启动时,先连接数据库版本表,把版本号和主程序的版本比较,如果新则从版本表中下载数据包到本地,Terminate掉主程序 并启动更新程序(Update.exe)
    需要给客户管理员做一个升级服务器的小程序,把所有改动做成压缩包,用Update.exe直接解压缩后,再启动主程序就好了//主程序启动时检查更新
    procedure Tlogon.FormShow(Sender: TObject);
    var s:string;
    begin
      ADOQ_Temp.Close;
      ADOQ_Temp.SQL.Clear;
      ADOQ_Temp.SQL.Text:='Select * From Ver';
      ADOQ_Temp.Open;
      if not ADOQ_Temp.Eof then
      begin
        S:=StringReplace(GetFileVersion(Application.ExeName),'.','', [rfReplaceAll]);
        if ADOQ_Temp['版本']>StrToInt(s) then    
        begin
          if MessageDlg('系统检查到有新版本,马上更新?',mtConfirmation,[mbYes,mbNo],0)=idYes then
          begin
            TblobField(ADOQ_Temp.FieldByName('程序')).savetofile(ExtractFilePath(Paramstr(0))+'Update.exe');
            TblobField(ADOQ_Temp.FieldByName('数据包')).savetofile(ExtractFilePath(Paramstr(0))+'Update.zip');
            ShellExecute(Handle,nil,Pchar(ExtractFilePath(Application.ExeName)+'Update.exe'), ' ', ' ',   0);
            Application.Terminate;
          end;
        end;
      end;
    end;//附:取程序版本号函数(转换成字符,程序中其它地方需要)
    function GetFileVersion(FileName: string): string;
      type
        PVerInfo = ^TVS_FIXEDFILEINFO;
        TVS_FIXEDFILEINFO = Record
          dwSignature: longint;
          dwStrucVersion: longint;
          dwFileVersionMS: longint;
          dwFileVersionLS: longint;
          dwFileFlagsMask: longint;
          dwFileFlags: longint;
          dwFileOS: longint;
          dwFileType: longint;
          dwFileSubtype: longint;
          dwFileDateMS: longint;
          dwFileDateLS: longint;
        end;
    var
        ExeNames: array [0 .. 255] of char;
        VerInfo: PVerInfo;
        Buf: pointer;
        Sz: word;
        L, Len: Cardinal;
    begin
        StrPCopy(ExeNames, FileName);
        Sz := GetFileVersionInfoSize(ExeNames, L);
        if Sz = 0 then
        begin
          Result := '';
          Exit;
        end;
        try
          GetMem(Buf, Sz);
          try
            GetFileVersionInfo(ExeNames, 0, Sz, Buf);
            if VerQueryValue(Buf, '\', pointer(VerInfo), Len) then
            begin
              Result := IntToStr(HIWORD(VerInfo.dwFileVersionMS)) + '.' +
                        IntToStr(LOWORD(VerInfo.dwFileVersionMS)) + '.' +
                        IntToStr(HIWORD(VerInfo.dwFileVersionLS)) + '.' +
                        IntToStr(LOWORD(VerInfo.dwFileVersionLS));
            end;
          finally
            FreeMem(Buf);
          end;
        except
          Result := '-1';
        end;
    end;//更新存入服务器数据库
    procedure TForm1.Button1Click(Sender: TObject);
    var VerNo:string;
    begin
      VerNo:=StringReplace(GetFileVersion(Application.ExeName),'.','', [rfReplaceAll]);
      M.Lines.Add('准备更新主程序...');
      try
       A.Close;
       A.SQL.Clear;
       A.SQL.Text:='Select * From Ver';
       A.Open;
       if A.Eof then
       begin
         M.Lines.Add('正在更新...(可能需要多等一会儿)');
         A.Close;
         A.SQL.Clear;
         A.SQL.Text:='Insert into Ver (版本,程序,数据包) Values ('+VerNo+',:程序,:数据包)';
         A.Parameters.ParamByName('程序').LoadFromFile(ExtractFilePath(Application.ExeName)+'Update.exe',ftBlob);
         A.Parameters.ParamByName('数据包').LoadFromFile(ExtractFilePath(Application.ExeName)+'Update.zip',ftBlob);
         A.ExecSQL;
         M.Lines.Add('已更新版本为'+VerNo);
       end else
       begin
         if A['版本']<StrToInt(VerNo) then
         begin
           M.Lines.Add('正在更新...(可能需要多等一会儿)');
           A.Close;
           A.SQL.Clear;
           A.SQL.Text:='Update Ver Set 版本='+VerNo+',程序=:程序,数据包=:数据包 ';
           A.Parameters.ParamByName('程序').LoadFromFile(ExtractFilePath(Application.ExeName)+'Update.exe',ftBlob);
           A.Parameters.ParamByName('数据包').LoadFromFile(ExtractFilePath(Application.ExeName)+'Update.zip',ftBlob);
           A.ExecSQL;
           M.Lines.Add('主程序已成功更新为: Ver:'+VerNo);
         end else
         M.Lines.Add('主程序无需更新');
       end;
      except
        M.Lines.Add('');
        M.Lines.Add('主程序更新出错!!!    请联络...');
        M.Font.Color:=clRed;
        exit;
      end;
    end;
      

  3.   

    我记得有个组件叫  AutoUpgrader
    去找找吧。很容易的
      

  4.   

    我的三层软件,最近自己做了一个的更新程序:(好用,可行)
    1、在服务器上安排一个表,用于存贮“下载文件包”。
    2、在客户端安排一个上传相关“下载文件包”的功能。
    3、编制一个“UpdateFile.exe”用于下载。
    4、主执行程序开始时,比较版本编号,有新的版本,显示“更新提示”。
    5、主执行程序调用“UpdateFile.exe”,下载:(方式)
    (1)下载主程序;
    (2)下载相关文件;
    (3)新安装模式;
    (4)返回主执行程序。
    6、也可在客户端执行时,自动检查,发现有新版本则自动从服务端下载!