比较\\MAINSERVER\DEPOT$\CAIGOU.EXE 和本地caigou.exe文件的大小,如果一样大则不用更新,并运行本地caigou.exe程序,不一样大小则自动下载替换本地文件,才写到运行本地程序的部分就写不下去了。
就是下面两句
Winexec('Notepad.exe',sw_Normal);winexec(PChar(ExtractFilePath(Paramstr(0))+'caigou.exe'),sw_Normal); //'E:\tj\work\update\caigou.exe'这两句我在新建的工程里可以运行成功,但在我的工程就不能打开caigou.exe
帮我看看procedure TForm1.FormShow(Sender: TObject);
var
lfile,sfile: file of Byte;
lfsize,sfsize:longint;
filename,serverpath:string;
begin
upinifile:=Tinifile.Create(ExtractFilePath(Paramstr(0))+'filelist.ini');
filename:=upinifile.Readstring('filelist','mainfile','caigou');AssignFile(lfile, ExtractFilePath(Paramstr(0))+'caigou.exe');
Reset(lfile);
lfsize := FileSize(lfile);assignfile(sfile,'\\mainserver\depot$\caigou.exe');
reset(sfile);
sfsize:=filesize(sfile);if  lfsize=sfsize then
begin
Winexec('Notepad.exe',sw_Normal);winexec(PChar(ExtractFilePath(Paramstr(0))+'caigou.exe'),sw_Normal); //'E:\tj\work\update\caigou.exe'
showmessage('不需要更新!!!!!!!!!!!');
end
else
begin
showmessage('需要更新');end;end;

解决方案 »

  1.   

    是啊。我就是用这个文件来更新caigou.exe,caigou.exe已经编译好了,现在用我这个工程问件来处理更新
    -------------------看个简易的
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    var
    lfile,sfile: file of Byte;
    lfsize,sfsize:longint;
    begin
    AssignFile(lfile, 'E:\tj\work\update\caigou.exe');
    Reset(lfile);
    lfsize := FileSize(lfile);assignfile(sfile,'\\mainserver\depot$\caigou.exe');
    reset(sfile);
    sfsize:=filesize(sfile);if  lfsize=sfsize then//如果两个文件大小一样
    begin
    Winexec('Notepad.exe',sw_Normal);//记事本可以打开
    winexec('E:\tj\work\update\caigou.exe',sw_Normal); //这个就不行了
    showmessage('不需要更新!!!!!!!!!!!');
    end
    else
    begin
    showmessage('需要更新');end;
    end;end.