IObjectWithSite - amidoinitrite?
-
I'm trying to do this error-free. I'm writing context menu shell extension that will navigate current Explorer window through IShellBrowser acquired through IObjectWithSite and so far I have this (omitting unimportant code): header file
class ATL_NO_VTABLE CShellTarget :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CShellTarget,&CLSID_ShellTarget>,
public IShellExtInit,
public IContextMenu,
public IObjectWithSiteImpl<CShellTarget>
...
private:
CComPtr<IShellBrowser> m_pShellBrowser;
...
};and here I override SetSite method, but I'm not sure if this code is OK
HRESULT CShellTarget::SetSite(IUnknown *pUnkSite)
{
ATLTRACE("IObjectWithSiteImpl::SetSite\n");IObjectWithSiteImpl<CShellTarget>::SetSite(pUnkSite); if (m\_spUnkSite!=NULL) { CComQIPtr<IServiceProvider>; sp = pUnkSite; sp->QueryService(SID\_SShellBrowser,IID\_IShellBrowser,(void\*\*)&m\_pShellBrowser); //verify m\_pShellBrowser etc... } else m\_pShellBrowser.Release();
return S_OK;
}It's hard to find one representative code sample of IObjectWithSite and Google isn't that much helpful. (btw yea I know about WM_GETISHELLBROWSER hack) Help is appreciated.