The new IBindHost interface

There has been a significant interface change in IBindHost, but it will not require any re-architecting by control authors. Well-behaved controls should require minimum code changes to compile and work correctly. Controls written using the ActiveX(TM) or BaseCtl frameworks will be shielded from this change, although they will still need to recompile to work with the new IBindHost. In the long term this change makes things easier for controls and cleaner for control containers. The sample code below demonstrates how this small change affects (actually reduces) the code for today's control author:

The new IBindHost:

    interface IBindHost : IUnknown {
        HRESULT CreateMoniker(
            [in] LPCOLESTR szName,
            [in] IBindCtx *pBC, // OPTIONAL parameter
            [out] IMoniker **ppMkResult,
            [in] DWORD dwReserved
        );
        HRESULT MonikerBindToStorage(
            [in] IMoniker *pMk, 
            [in] IBindCtx *pBC, // OPTIONAL parameter
            [in] IBindStatusCallback *pBSC,
            [in] REFIID riid,
            [out] void **ppvObj
        );

        HRESULT MonikerBindToObject(
            [in] IMoniker *pMk, 
            [in] IBindCtx *pBC, // OPTIONAL parameter
            [in] IBindStatusCallback *pBSC,
            [in] REFIID riid,
            [out] void **ppvObj
        );
    };


Old control code:
    // after QueryInterface for IID_IBindHost
    if (pBindHost) {
        pBindHost->ParseDisplayName(szName, &pMk);
        pBindHost->GetBindCtx(0, &pBC);
        RegisterBindStatusCallback(pBC, pBSC, 0);
    }
    else {
        CreateURLMoniker(NULL, szName, &pMk);
        CreateAsyncBindCtx(0, pBSC, NULL, &pBC);
    }
    pMk->BindToStorage(pBC, NULL, IID_IStream /* or whatever */, &pStream);

New control code - fewer lines!:

    // after QueryInterface for pBindHost
    if (pBindHost) {
        pBindHost->CreateMoniker(szName, &pMk);
        // LINE REMOVED: pBindHost->GetBindCtx(0, &pBC);
        // LINE REMOVED: RegisterBindStatusCallback(pBC, pBSC, 0);
        pBindHost->MonikerBindToStorage(pMk, NULL, pBSC, IID_IStream /* or whatever */, &pStream);
    }
    else {
        CreateURLMoniker(NULL, szName, &pMk);
        CreateAsyncBindCtx(0, pBSC, NULL, &pBC);
        pMk->BindToStorage(pBC, NULL, IID_IStream /* or whatever */, &pStream);
    }
    // LINE REMOVED: pMk->BindToStorage(pBC, NULL, IID_IStream /* or whatever */, &pStream);