CSDN博客

img lingll

Implemented IDownloadManager

发表于2005/8/11 17:53:00  4915人阅读

分类: L_E(多页面浏览器) 编程心得

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

0 0

相关博文

我的热门文章

img
取 消
img