利用TIdHttp控件下载文件和vista的兼容问题,高手进来看看

housisong 2007-05-17 05:01:43
下载代码在98\2000\xp下都没有问题;
但在vista下不能完成下载,症状为接收到1次或2次数据包后(有时也能收到更多的数据,但都没有超过3秒)就再也接收不到数据(跟踪发现代码停在Windows的网络Select函数上)
代码使用过Delphi7和turboDelphi编译,并尝试了Indy9和Indy10都一样;

完整测试源代码:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls,IdHttp,IdComponent;

type
TForm1 = class(TForm)
Button1: TButton;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FHttpCli : TIdHttp;
FStream : TStream;
procedure HTTPWork(Sender: TObject; AWorkMode: TWorkMode;const AWorkCount: Integer);
public
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
FStream :=TStringStream.Create('');
FHttpCli := TIdHttp.Create(nil);
self.FHttpCli.OnWork := self.HTTPWork;
end;

procedure TForm1.HTTPWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
self.ProgressBar1.Position:=AWorkCount;
self.ProgressBar1.Refresh;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
url :string;
begin
url:='http://p.blog.csdn.net/images/p_blog_csdn_net/housisong/280093/o_xinkong_big.jpg';
FHttpCli.Head(url);
FHttpCli.Request.ContentRangeStart := 0;
FHttpCli.Request.ContentRangeEnd := FHttpCli.Response.ContentLength;
self.ProgressBar1.Min:=0;
self.ProgressBar1.Max:=FHttpCli.Response.ContentLength;

FHttpCli.Get(url, self.FStream); //下载
end;


end.
...全文
355 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
housisong 2007-06-16
  • 打赏
  • 举报
回复
还是有问题
在某些局域网中,还是会没有响应,包括那些专门的下载软件也一样会没有响应,应该是vista的问题
ly_liuyang 2007-05-25
  • 打赏
  • 举报
回复
Vista Ultimate b6000 EN 没此问题~
housisong 2007-05-24
  • 打赏
  • 举报
回复
应该是早期测试版vista的兼容性问题,在正式版vista中好像没有这个问题
postren 2007-05-19
  • 打赏
  • 举报
回复
没Vista
housisong 2007-05-18
  • 打赏
  • 举报
回复
谁安装了Delphi2007和vista的帮忙编译以下

1,593

社区成员

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

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