关于IEdownload控件的使用(200分!急!!)(200分)

  • 主题发起人 主题发起人 goldenfaith
  • 开始时间 开始时间
G

goldenfaith

Unregistered / Unconfirmed
GUEST, unregistred user!
请用过IEdownload控件的朋友告知一下该控件的具体使用方法
谢谢!
 
如果是破解版的,发过来我帮你研究。
yaya8163@hotmail.com
 
他不是有很多例子程序吗,看看不就知道了,
如果你没有我可以发给你呀
 
to LiChaoHui :
谢谢!我的邮箱是wangyang_801031@hotmal.net
 
http://service.lonetear.com/delphi/dispdoc.asp?id=1340
下载,解压。在其Download目录中有控件和例子。
---------------------------------------------------
unit Downloaddemo_U;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
urlmon, IEDownload, StdCtrls, wininet;

type
TForm1 = class(TForm)
Button1: TButton;
memo1: TMemo;
memo2: TMemo;
IEDownload1: TIEDownload;
procedure Button1Click(Sender: TObject);
procedure IEDownload1Progress(Sender: TBSCB; ulProgress, ulProgressMax,
ulStatusCode: Cardinal; szStatusText: PWideChar; ElapsedTime, Speed,
EstimatedTime: string);
procedure IEDownload1Data(Sender: TBSCB; var Buffer: PByte;
var BufLength: Cardinal);
procedure IEDownload1Complete(Sender: TBSCB; Stream: TStream;
Result: HRESULT);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
IEDownload1.go('http://www.microsoft.com');
end;

procedure TForm1.IEDownload1Progress(Sender: TBSCB; ulProgress,
ulProgressMax, ulStatusCode: Cardinal; szStatusText: PWideChar;
ElapsedTime, Speed, EstimatedTime: string);
var
s: string;
begin
s := BindstatusText(ulStatusCode);
if ulStatusCode = BINDSTATUS_DOWNLOADINGDATA then
s := S + ' (' + InttoStr(ulProgress) + '/' + InttoStr(ulProgressMax) + ')';
memo1.lines.add(s);
end;

procedure TForm1.IEDownload1Data(Sender: TBSCB; var Buffer: PByte;
var BufLength: Cardinal);
begin
memo2.lines.add(pchar(buffer));
end;

procedure TForm1.IEDownload1Complete(Sender: TBSCB; Stream: TStream;
Result: HRESULT);
begin
if (Result = S_OK) then
memo1.lines.add('Download complete...')
else
memo1.lines.add(Errortext(Result) + ' ' + ResponseCodeText(Sender.ResponseCode));
end;

end.

 
to zw84611:
谢谢你的帮助,我还想问一下。
我在看别人用这个控件做的一个IE下载的插件,但是下载下来的文件的文件名是怪字符,
所以文件不能用。其源码中IEDownload_u 这个单元中加了一个GetLocalFile函数。
代码如下:
function TDownloadForm.GetLocalFile(Url: string): string;
var
Reg: TRegistry;
begin
if Visible then Hide; // Hide form when popup save dialog
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('Software/Microsoft/Internet Explorer', True) then
SaveDialog.InitialDir:= Reg.ReadString('Download Directory');
SaveDialog.FileName:=FilenameFromUrl(Url);//这里的filename是正确的。
if SaveDialog.Execute then
begin
Result:=SaveDialog.FileName;//到这里filename就会出现乱码!!!
Reg.WriteString('Download Directory', ExtractFileDir(Result));
end
else
Result:='';
finally
Reg.Free;
end;
Show; // restore form
end;
 
又一个例程
unit Resumedemo_U;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
urlmon, IEDownload, StdCtrls, wininet;

type
TForm1 = class(TForm)
Button1: TButton;
memo1: TMemo;
IEDownload1: TIEDownload;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure IEDownload1Progress(Sender: TBSCB; ulProgress, ulProgressMax,
ulStatusCode: Cardinal; szStatusText: PWideChar; ElapsedTime, Speed,
EstimatedTime: string);
procedure IEDownload1Complete(Sender: TBSCB; Stream: TStream;
Result: HRESULT);
function IEDownload1Response(Sender: TBSCB; dwResponseCode: Cardinal;
szResponseHeaders, szRequestHeaders: PWideChar;
out szAdditionalRequestHeaders: PWideChar): HRESULT;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin

if Button1.Caption <> 'Pause' then
begin
IEDownload1.go('http://hnhttp.skycn.net/down/KV3021220.EXE', 'OVI386.EXE');
Button1.Caption := 'Pause';
end else
begin
IEDownload1.Cancel;
Button1.Caption := 'Resume';
end;
end;

procedure TForm1.IEDownload1Progress(Sender: TBSCB; ulProgress,
ulProgressMax, ulStatusCode: Cardinal; szStatusText: PWideChar;
ElapsedTime, Speed, EstimatedTime: string);
var
s: string;
begin
s := BindstatusText(ulStatusCode);
if ulStatusCode = BINDSTATUS_DOWNLOADINGDATA then
s := S + ' (' + InttoStr(ulProgress) + '/' + InttoStr(ulProgressMax) + ')';
memo1.lines.add(s);
Label1.Caption := 'Estimated time left: '+ EstimatedTime;
end;

procedure TForm1.IEDownload1Complete(Sender: TBSCB; Stream: TStream;
Result: HRESULT);
begin
if (Result = S_OK) then
begin
memo1.lines.add('Download complete...');
Button1.Caption := 'Start Download';
end
else
if (Result = E_ABORT) and (Sender.ResponseCode = 206) then
memo1.lines.add('Cancelled by user...')
else
if (Result = E_ABORT) and (Sender.ResponseCode = 416) then
memo1.lines.add('File allready downloaded...') else
memo1.lines.add(Errortext(Result) + ' ' + ResponseCodeText(Sender.ResponseCode));
end;

function TForm1.IEDownload1Response(Sender: TBSCB;
dwResponseCode: Cardinal; szResponseHeaders, szRequestHeaders: PWideChar;
out szAdditionalRequestHeaders: PWideChar): HRESULT;
begin
if dwResponseCode = 206 then
memo1.lines.add('Resume supported by server...') else
memo1.lines.add('Resume not supported by server...');
Result := S_OK;
end;

end.

 
to LiChaoHui:
请你帮忙看看我贴出来的哪个函数,错误的地方已经指出来了,但不知道为什么会了错.
谢谢!
 
看一下前面的Url的值是否正确,
跟踪到FilenameFromUrl里面,看执行的是否正确
 
不应该,SaveDialog.Execute后如果手工输入,还是乱码吗?
 
to LiChaoHui:
前面的URL是正确的,就是到SaveDialog.Execute会出错。
to zw84611:
手工输入也不行。
谢谢
 
不应该,你把SaveDialog.FileName等于一个常量,看还会出错吗?
 
to zw84611:
还是不行啊!要不我这边的程序发给你帮忙看看
给我你的邮箱.谢
 
zw84611@sina.com
 
可能是这个函数写得有问题
FilenameFromUrl(Url)
 
to LiChaoHui:
请帮我看看这个函数错在哪里了啊?
 
我没有这个函数的源代码呀
 
to LiChaoHui:
请给我你的信箱,我给你发一份。谢谢!!
 
lichaohui@old.371.net
 
后退
顶部