以下是我的代码
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.
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.
解决方案 »
- 怎么给SQLite数据库加密?
- 请教Delphi里面boolean初始化的值
- MainMenu1 图标显示问题
- =?GB2312?Q?=C4=E3=BA=C3?= 的解码方法.
- 在新窗体中打开image,就会出错,为什么?
- dbgrid显示问题,在线等
- 请教一个visio问题.
- 一个程序员辛辛苦苦一辈子,是为了什么?
- 小弟刚做一手机软件欢迎测试,http://ljwsms.home.chinaren.com/
- 两位 斑竹 (怎样判断单击了一个按钮 if 单击 then ....(LWWL))还没解决呢 救命啊》》》》》》》》》》》》
- 我一般不说倒粪的事情。不过有点太可恶的人。
- dxDBGrid的使用问题,有用过的朋友进来帮忙!
if FileDateTime<strtodatetime(Appini.ReadString(files[i],'datetime','2000-01-01')) then
begin
result:=true;
break;
end;
except
end;
finally
AppIni.free;
// files.Free;
if FileDateTime<strtodatetime(Appini.ReadString(files[i],'datetime','2000-01-01')) then
begin
result:=true;
break;
end;
except
end;
finally
AppIni.free;
// files.Free;