屏蔽文件下载前的提示窗口(100分)

  • 主题发起人 主题发起人 MYSBS
  • 开始时间 开始时间
M

MYSBS

Unregistered / Unconfirmed
GUEST, unregistred user!
通过IE下载时,会出现“文件下载”的对话框.我想屏蔽此对话框,并默认“在当前位置运行该程序(R)”的选项。
我想知道这些设置在注册表中的位置,提供相应的Delphi代码处理该事件更好!
 
难道没有人想要这100分吗?
 
好像不知道,我记得当初下载MSN5.0的时候,微软的主页上还专门提示说应该选中“在当前
位置运行该程序”选项,然后点击确定的页面提示啊。没有见到微软用你说的办法,大概
是不行吧?
 
TO:ZQW0117
既然是个设置,我想应该是在数据库中保存的,我首先想到可能在注册表,但不知道在哪里。谢谢你的参与!
 
下载不提示,不就是病毒吗?如果有这种方法,病毒早就泛滥了!
 
TO:yinxuetao
你清除掉“在打开这种类型的文件前始终询问”的选择试试!看是否下载了病毒。呵呵,开个玩笑!
 
接受答案!
 
各位有没有比较建设性的建议,我的分很难分配啊,如果用Delphi控件从指定IP地址下载可以不提示,请给我代码。我以前是用ShellExecute到指定IP下载,准备通过修改注册表,去掉提示框,下载完后在恢复注册表。看来没人给我提示了。
 
再帮你顶顶,等等看看有没有高手回答!
 
我想自动下载到特定的目录,可以吗??
 
谢谢datasoft,这几天比较忙,没有上网。
当然可以,麻烦你告诉我。
 
只是下载的话,直接用API函数UrlDownloadToFile就可以了。
如果要像IE一样有流量监测,就要实现IBindStatusCallback接口,
调用方式如下:
UrlDownloadToFile(nil,Pchar(Source_file),Pchar(Dest_file),0,StatusCallback)

 
如果不是可执行的文件(如zip文件)可以通过修改注册表来实现,好像是修改EditFlag,但是可执行程序好像不行
 
TO:gonghh
能不能提供实现IBindStatusCallback接口的一个事例,谢谢!
TO:独帅
EditFlag的完整路径是什么,比如HKEY_CURRENT_USER/Control Panel/Cursors/Schemes,谢谢
 
对于.RAR文件:
HKEY_CLASSES_ROOT/WinRAR
右面的EditFlags如果为00 00 01 00则不提示直接打开
 
太忙了,好久没来了.你要的代码贴给你.
=====================================================
///////////////////////////////////////////////////////////////////////////////
// 类 名 称: 文件下载类
// 版 本: TDownFile V0.1.2003.1006
// 作 者: gonghh
// 适用平台: win2000 测试通过
// 功能说明: 单线程文件下载
//
///////////////////////////////////////////////////////////////////////////////
unit uTDownFile;

interface
uses SysUtils, Windows, UrlMon, ActiveX,Classes,shellapi;

type //下载流量状态回调接口类
TOnProgressEvent = procedure(ulProgress, ulProgressMax, ulStatusCode: integer;szStatusText:String) of object;
TOnCompleteEvent = procedure(Source_file,Dest_file:String;blStatus:boolean;ErrMessage:String) of object;

TBindStatusCallback = class(TObject, IBindStatusCallback)
protected // IUnknown
FRefCount: Integer;
function QueryInterface(const IID: TGUID; out Obj): Integer; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
public // IBindStatusCallback
FProgress : TOnProgressEvent;
FComplete : TOnCompleteEvent;
function OnStartBinding(dwReserved: DWORD; pib: IBinding): HResult; stdcall;
function GetPriority(out nPriority): HResult; stdcall;
function OnLowResource(reserved: DWORD): HResult; stdcall;
function OnProgress(ulProgress, ulProgressMax, ulStatusCode: ULONG;szStatusText: LPCWSTR): HResult; stdcall;
function OnStopBinding(hresult: HResult; szError: LPCWSTR): HResult; stdcall;
function GetBindInfo(out grfBINDF: DWORD; var bindinfo: TBindInfo): HResult; stdcall;
function OnDataAvailable(grfBSCF: DWORD; dwSize: DWORD; formatetc: PFormatEtc;stgmed: PStgMedium): HResult; stdcall;
function OnObjectAvailable(const iid: TGUID; punk: IUnknown): HResult; stdcall;
end;


TThreadDown =class(TThread) //下载线程类。
private
Source_file : string;
Dest_file : string;
StatusCallback : TBindStatusCallback;
protected
procedure Execute; override;
public
constructor Create(URL,FileName: String ; StatusCB: TBindStatusCallback);overload;
end;


TDownFile=class(TComponent) //文件下载控件
private
FOnProgress: TOnProgressEvent;
RevedByte : TBindStatusCallback;
FOnComplete: TOnCompleteEvent;
procedure SetOnProgress(const Value: TOnProgressEvent); //下载进度
procedure SetOnComplete(const Value: TOnCompleteEvent); //下载完成
public
constructor Create(AOwner: TComponent);reintroduce;
destructor Destroy; reintroduce;
procedure ThreadDownFile(Source,Dest:string);
procedure DownFile(Source,Dest:string);
published
property OnComplete:TOnCompleteEvent read FOnComplete write SetOnComplete;
property OnProgress:TOnProgressEvent read FOnProgress write SetOnProgress;
end;
implementation

{ TBindStatusCallback }
function TBindStatusCallback._AddRef: Integer;
begin
Inc(FRefCount);
Result := FRefCount;
end;

function TBindStatusCallback._Release: Integer;
begin
Dec(FRefCount);
Result := FRefCount;
end;

function TBindStatusCallback.GetBindInfo(out grfBINDF: DWORD;
var bindinfo: TBindInfo): HResult;
begin
Result := E_NOTIMPL;
end;

function TBindStatusCallback.GetPriority(out nPriority): HResult;
begin
Result := E_NOTIMPL;
end;

function TBindStatusCallback.OnDataAvailable(grfBSCF, dwSize: DWORD;
formatetc: PFormatEtc; stgmed: PStgMedium): HResult;
begin
Result := E_NOTIMPL;
end;

function TBindStatusCallback.OnLowResource(reserved: DWORD): HResult;
begin
Result := E_NOTIMPL;
end;

function TBindStatusCallback.OnObjectAvailable(const iid: TGUID;
punk: IInterface): HResult;
begin
Result := E_NOTIMPL;
end;

function TBindStatusCallback.OnStartBinding(dwReserved: DWORD;
pib: IBinding): HResult;
begin
Result := E_NOTIMPL;
end;

function TBindStatusCallback.OnStopBinding(hresult: HResult;
szError: LPCWSTR): HResult;
begin
Result := E_NOTIMPL;
end;

function TBindStatusCallback.QueryInterface(const IID: TGUID;
out Obj): Integer;
begin
if GetInterface(IID, Obj) then Result := S_OK
else Result := E_NOINTERFACE;
end;

function TBindStatusCallback.OnProgress(ulProgress, ulProgressMax,
ulStatusCode: ULONG; szStatusText: LPCWSTR): HResult;
begin
if Assigned(FProgress) then
FProgress(ulProgress,ulProgressMax,ulStatusCode,szStatusText);
Result := S_OK;
end;



//=============================================================================

{ TDownFile }

constructor TDownFile.Create(AOwner: TComponent);
begin
RevedByte:=TBindStatusCallback.Create;
inherited;
end;

destructor TDownFile.Destroy;
begin
RevedByte.Free;
end;

procedure TDownFile.SetOnComplete(const Value: TOnCompleteEvent);
begin
FOnComplete := Value;
if Assigned(FOnComplete) then ;
RevedByte.FComplete := FOnComplete;
end;

procedure TDownFile.SetOnProgress(const Value: TOnProgressEvent);
begin
FOnProgress := Value;
if Assigned(FOnProgress) then ;
RevedByte.FProgress := FOnProgress;
end;

procedure TDownFile.ThreadDownFile(Source, Dest: string);
var
ThreadDown:TThreadDown;
begin
ThreadDown:=TThreadDown.Create(Source, Dest,RevedByte);
ThreadDown.Resume;
end;

procedure TDownFile.DownFile(Source, Dest: string);
var
blDownOK:boolean;
ErrMessage:String;
begin
ErrMessage:='';
blDownOK:=false;
try
if UrlDownloadToFile(nil,Pchar(Source),Pchar(Dest),0,RevedByte)=0 then
blDownOK:=true;
except on e:exception do
ErrMessage:=e.Message;
end;
if Assigned(RevedByte.FComplete) then
RevedByte.FComplete(Source,Dest,blDownOK,ErrMessage);
end;


//==============================================================================
{ TThreadDown }

constructor TThreadDown.Create(URL, FileName: String;StatusCB: TBindStatusCallback);
begin
Source_file := URL;
Dest_file := FileName;
StatusCallback := StatusCB;
FreeOnTerminate:=true;
inherited Create(true);
end;

procedure TThreadDown.Execute;
var
blDownOK:boolean;
ErrMessage:String;
begin
ErrMessage:='';
blDownOK:=false;
try
if UrlDownloadToFile(nil,Pchar(Source_file),Pchar(Dest_file),0,StatusCallback)=0 then
blDownOK:=true;
except on e:exception do
ErrMessage:=e.Message;
end;
if Assigned(StatusCallback.FComplete) then
StatusCallback.FComplete(Source_file,Dest_file,blDownOK,ErrMessage);
end;

end.

 
配分完成,请查收!
 
配分完成,请查收!
 
后退
顶部