以下是我的代码
function TForm_Update.ExistNewFile:boolean;
var i,iFileHandle:integer;
    FileDateTime:TDateTime;
begin
   result:=false;
  //下载文件
   files.Clear;
   try
      HTTPFiles.InputFileMode := true;
      HTTPFiles.OutputFileMode := FALSE;
      HTTPFiles.ReportLevel := Status_Basic;
      HTTPFiles.Body:=g_path+'update/update.ini';
      if copy(Edt_url.Text,length(edt_url.Text),1)<>'/' then Edt_url.Text:=Edt_url.Text+'/';
      HTTPFiles.Get(Edt_url.Text+sys_id+'.htm');
   except
      MessageBox(handle,'取得升级信息出错!','错误提示',MB_OK+MB_ICONERROR);
      exit;
   end;
   files.Clear;
   try
              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[i],fmOpenRead);
                     FileDateTime:=FileDateToDateTime(FileGetDate(iFileHandle));
                     FileClose(iFileHandle);
                    
\\升级                     if FileDateTime<strtodatetime(Appini.ReadString(files[i],'datetime','2000-01-01')) then
                     begin
                            result:=true;
                            break;
                     end;
              except
              end;
   finally
              AppIni.free;
             // files.Free;   end;
   result:=true;
end;procedure TForm_Update.HTTPFilesPacketRecvd(Sender: TObject);
begin
   Gauge_process.Progress:=Gauge_process.Progress+1;
   if Gauge_process.Progress>=Gauge_process.MaxValue then Gauge_process.Progress:=Gauge_process.MaxValue-1000;
end;procedure TForm_Update.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
   CanClose:=true;
   if HTTPFiles.Connected then
   begin
       if MessageBox(handle,'正在下载文件,要退出吗?','信息提示',MB_YESNO+MB_ICONQUESTION)=ID_YES then CanClose:=true else CanClose:=false;
   end;
   if btn_next.Caption='完成升级' then
   begin
       if MessageBox(handle,'文件下载已经完成,但并没有更新文件,要退出吗?','信息提示',MB_YESNO+MB_ICONQUESTION)=ID_YES then CanClose:=true else CanClose:=false;
   end;
end;end.

解决方案 »

  1.   

    我个人觉得是这个有问题
    if FileDateTime<strtodatetime(Appini.ReadString(files[i],'datetime','2000-01-01')) then
                         begin
                                result:=true;
                                break;
                         end;
                  except
                  end;
       finally
                  AppIni.free;
                 // files.Free;
      

  2.   

    我个人觉得是这个有问题
    if FileDateTime<strtodatetime(Appini.ReadString(files[i],'datetime','2000-01-01')) then
                         begin
                                result:=true;
                                break;
                         end;
                  except
                  end;
       finally
                  AppIni.free;
                 // files.Free;