求救!用idhttp组件下载的问题,散分50!

hxdosa 2004-10-21 03:10:39
我做的一个升级程序先用ftp下载,当21端口被封时改成http下载
其中http线程下载时出现问题
procedure THttpThread.execute;
var
newVersion2,exe,temp:string;
close:Boolean;
Filenames:TStrings;
i:integer;
ini:TiniFile;
begin
inherited;
connected:=false;
failed:=false;
alive:=1;
form1.idHTTP1.Host:='www.medlink.com.cn';
form1.Gauge1.Visible:=false;
form1.Label3.Caption:='连接耗时'+intTostr(form1.tick)+'秒';
try
form1.idhttp1.Connect(delay);
except
on E: Exception do
begin
err:=e.Message;
failed:=true;
exit;
end;
end;
form1.Memo1.Lines.Add('连接上服务器');
connected:=true;
form1.BitBtn2.Enabled:=true;
form1.BitBtn2.Caption:='停止';
form1.BitBtn3.Enabled:=false;
form1.Gauge1.Visible:=true;
form1.Label3.Visible:=false;
self.failed:=false;
try
filenames:=TStringList.create;
×××××××××××××××××××××××××××××××××××××××××××
newversion2:=form1.GetNewVersion2(filenames,exe,close); //返回下载文件名
if form1.DownloadFile2(filenames) then
begin
showmessage(newversion2);
×××××××××××××××××××××××××××××××××××××××××××
if not DirectoryExists(extractfilepath(paramstr(0))+'\update') then
mkdir(extractfilepath(paramstr(0))+'\update');
if not DirectoryExists(extractfilepath(paramstr(0))+'\backup') then
mkdir(extractfilepath(paramstr(0))+'\backup');
for i:=0 to filenames.Count-1 do
begin
copyfileto(extractfilepath(paramstr(0))+filenames[i],extractfilepath(paramstr(0))+'backup\'+filenames[i]);
DeleteFile(extractfilepath(paramstr(0))+filenames[i]);
copyfileto(extractfilepath(paramstr(0))+'update\'+filenames[i],extractfilepath(paramstr(0))+filenames[i]);
end;
form1.finished:=true;
if not form1.aborted then
begin
ini:=Tinifile.Create(extractfilepath(paramstr(0))+'\sysconf.ini');
temp:=Encrypt(newVersion2);
ini.WriteString('VERSION','VALUE',temp);
Application.MessageBox('升级成功!','智能升级0.2',mb_ok+MB_ICONINFORMATION);
postMessage(Application.Handle,SX_CLOSE,0,0);
end;
end
else
failed:=true;
except
failed:=true;
end;
end;
这段是读ini 文件的函数
function TForm1.GetNewVersion2(var fnames: TStrings; var exefile: string;
var close: Boolean): string;
var
ini:TiniFile;
temp,temp1:string;
i,j:integer;
temp2:TFileStream;
begin
Result:='';
fnames.Clear;
temp:=GetCurrentDir+'\version.ini';
temp2:=TFileStream.Create(temp,fmCreate);
form1.IdHTTP1.Get('http://www.medlink.com.cn/update/version.ini',temp2);
ini:=TiniFile.Create(temp);
result:=ini.ReadString('VERSION','VALUE','');
temp:=ini.ReadString('VERSION','FILENAME','');
exefile:=ini.ReadString('VERSION','EXECUTE','');
if ini.ReadString('VERSION','APPCLOSE','-1')='1' then
close:=true
else
close:=false;
ini.Free;
temp1:='';
j:=0;
for i:=1 to length(temp) do
begin
if temp[i]<>';' then
temp1:=temp1+temp[i]
else
begin
fnames.Insert(j,temp1);
temp1:='';
j:=j+1;
end;
end;
DeleteFile(extractfilepath(paramstr(0))+'update\version.ini');
end;
同样的代码在ftp线程可以返回文件名和参数
但是在http线程代码执行后ini文件下载成功但是返回的参数和文件名为空
...全文
271 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ohzqo 2004-10-26
  • 打赏
  • 举报
回复
关注,解决完告诉方法
ksaiy 2004-10-25
  • 打赏
  • 举报
回复
http://www.delphibox.com/article.asp?articleid=1037

你去这里下载吧.比较详细了。
wenjianyao 2004-10-25
  • 打赏
  • 举报
回复
忘记说邮箱了,ghostbox@126.com
wenjianyao 2004-10-25
  • 打赏
  • 举报
回复
给我发一分,再简单说明,最好有demo。我帮你调试一下,以前遇到过
yzty 2004-10-25
  • 打赏
  • 举报
回复
能不能多贴一些代码
backstreetNewhua 2004-10-23
  • 打赏
  • 举报
回复
顶一下
zwb666 2004-10-23
  • 打赏
  • 举报
回复
顶一下
sobigbug 2004-10-22
  • 打赏
  • 举报
回复
顶一下
a9 2004-10-22
  • 打赏
  • 举报
回复
关注一下~
hxdosa 2004-10-22
  • 打赏
  • 举报
回复
那位大大给点提示啊

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧