本文整理汇总了C++中CComObject::AddHost方法的典型用法代码示例。如果您正苦于以下问题:C++ CComObject::AddHost方法的具体用法?C++ CComObject::AddHost怎么用?C++ CComObject::AddHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComObject
的用法示例。
在下文中一共展示了CComObject::AddHost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RegisterTemporaryHandler
HRESULT CProtocolHandlerRegistrar::RegisterTemporaryHandler(
LPCWSTR lpszScheme,
LPCWSTR lpszHost,
RT tResourceID)
{
CritSectLock lock(m_CriticalSection);
BOOL registered = FALSE;
CComObject<CF> *pHandlerFactory = NULL;
CComPtr<IClassFactory> pClassFactory;
// lookup class factory for lpszScheme
if (!m_ClassFactories.Lookup(lpszScheme, pClassFactory))
{
// don't have yet, create class factory object
IF_FAILED_RET(CComObject<CF>
::CreateInstance(&pHandlerFactory));
pClassFactory = pHandlerFactory;
// init classfactory object
IF_FAILED_RET(pHandlerFactory->Init(
lpszScheme));
}
else
{
// have class factory
registered = TRUE;
pHandlerFactory = (CComObject<CF> *)pClassFactory.p;
}
// add the host
IF_FAILED_RET(pHandlerFactory->AddHost(
lpszHost, tResourceID));
// register protocol handler
if (!registered)
{
// get IInternetSession
CComPtr<IInternetSession> pInternetSession;
IF_FAILED_RET(CoInternetGetSession(0, &pInternetSession, 0));
IF_FAILED_RET(pInternetSession->RegisterNameSpace(
pClassFactory,
CTemporaryProtocolFolderHandler::CLSID,
lpszScheme,
0, NULL, 0));
// store classfactory object
m_ClassFactories[lpszScheme] = pClassFactory;
}
return S_OK;
}