Implemented IDownloadManager

王朝other·作者佚名  2006-01-10
宽屏版  字体: |||超大  

Implemented IDownloadManager

IDownloadManager有一个成员函数,原型如下,

HRESULT Download(

IMoniker *pmk,

IBindCtx *pbc,

DWORD dwBindVerb,

LONG grfBINDF,

BINDINFO *pBindInfo,

LPCOLESTR pszHeaders,

LPCOLESTR pszRedir,

UINT uiCP

);

IMoniker,IBindCtx,BINDINFO,可能会比较麻烦,没关系,这里有现成的,

http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip

(引用页,http://www.mvps.org/emorcillo/en/code/vb6/wbframe.shtml)

有源码,可以自己编译,然后那个odl文件这样写就行了,

interface IDownloadManager;

[

odl,

uuid(988934A4-064B-11D3-BB80-00104B35E7F9), // IID_IDownloadManager

]

interface IDownloadManager : IUnknown

{

HRESULT Download(

[in] IMoniker *pmk, // Identifies the object to be downloaded

[in] IBindCtx *pbc, // Stores information used by the moniker to bind

[in] LONG dwBindVerb, // The action to be performed during the bind

[in] LONG grfBINDF, // Determines the use of URL encoding during the bind

[in] BINDINFO *pBindInfo, // Used to implement IBindStatusCallback::GetBindInfo

//[in] LPCOLESTR pszHeaders, // Additional headers to use with IHttpNegotiate

[in] long pszHeaders,

//[in] LPCOLESTR *pszRedir, // The URL that the moniker is redirected to

[in] long pszRedir,

[in] LONG uiCP // The code page of the object's display name

);

};

这里,我把LPCOLESTR pszHeaders 改为了 long pszHeaders,因为这个参数及另一个在这里用不着,所以这样改也无所谓

参考自 http://download.microsoft.com/download/6/8/3/683DB9FE-8D61-4A3C-B7B8-3169FF70AE9F/ie55_lib.exe

vb代码,需要Implements IServiceProvider,IDownloadManager然后在 IServiceProvider_QueryService中,

If IsEqualGUID(guidService, IID_IDownloadManager) And _

IsEqualGUID(riid, IID_IDownloadManager) Then

Dim oDM As IDownloadManager

Set oDM = Me

odm.AddRef

MoveMemory ppvObject, oDM, 4&

Else

' The service or interface is

' not supported

Err.Raise E_NOINTERFACE

End If

再有就是,IDownloadManager_Download中,

Private Sub IDownloadManager_Download(ByVal pmk As olelib.IMoniker, ByVal pbc As olelib.IBindCtx, ByVal dwBindVerb As Long, ByVal grfBINDF As Long, pbindinfo As olelib.BINDINFO, ByVal pszHeaders As Long, ByVal pszRedir As Long, ByVal uiCP As Long)

Dim tUrl$

Dim Cancel&

'获取下载地址

tUrl = SysAllocString(pmk.GetDisplayName(pbc, Nothing))

'取消下载的话,Cancel=1

If Cancel = 1 Then

Else

Err.Raise S_OK

End If

End Sub

代码参考自,http://www.euromind.com/iedelphi/downloadmanager.htm

一些相关链接

HOW TO: Implement a Custom Download Manager

(http://support.microsoft.com/default.aspx?scid=kb;en-us;327865)Implementing

a Custom Download Manager

(http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/ext/overview/downloadmgr.asp)

lingll

lingll2001@21cn.com

lingll.yeah.net

2005-8-11

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有