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’)) THEN
begin
result:=true;
break;
end;
except
end;
finally
AppIni.free;
files.Free;
end;
end;
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;