当前位置: 首页>>代码示例>>C++>>正文


C++ IDispatchPtr类代码示例

本文整理汇总了C++中IDispatchPtr的典型用法代码示例。如果您正苦于以下问题:C++ IDispatchPtr类的具体用法?C++ IDispatchPtr怎么用?C++ IDispatchPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IDispatchPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetCustomDocUIHandler

HRESULT WebBrowserEventSinker::SetCustomDocUIHandler(LPDISPATCH lpDisp)
{
	if(lpDisp == NULL)
		return E_INVALIDARG;

	IWebBrowser2Ptr pWebBrowser2;
	HRESULT hr = lpDisp->QueryInterface(IID_IWebBrowser2, (void**)&pWebBrowser2);

	if(SUCCEEDED(hr) && pWebBrowser2)
	{
		IDispatchPtr pDoc;
		hr = pWebBrowser2->get_Document(&pDoc);

		if(SUCCEEDED(hr) && pDoc)
		{
			ICustomDocPtr pCustDoc;
			hr = pDoc->QueryInterface(IID_ICustomDoc, (void**)&pCustDoc);
			if(SUCCEEDED(hr) && pCustDoc != NULL)
			{				
				IDocHostUIHandler* pUIHandler;
				CreateObjectInterface<CDocHostUIHandler, IDocHostUIHandler>(NULL, &pUIHandler);

				if (pUIHandler)
					pCustDoc->SetUIHandler(pUIHandler);

				pUIHandler->Release();
			}
		}
	}

	return hr;
}
开发者ID:Johnny-Martin,项目名称:ComBase,代码行数:32,代码来源:WebbrowserEventSinker.cpp

示例2: assert

HRESULT vmsDomHelper::GetWindowDocument(IHTMLWindow2* pWnd, IHTMLDocument2** ppDoc)
{
	assert (pWnd != NULL && ppDoc != NULL);
	if (!ppDoc)
		return E_INVALIDARG;
	*ppDoc = NULL;
	if (!pWnd)
		return E_INVALIDARG;

	HRESULT hr = pWnd->get_document (ppDoc);

	if (*ppDoc)
		return hr;

	IWebBrowser2Ptr spWB;
	GetWebBrowser (pWnd, &spWB);

	if (spWB != NULL)
	{
		IDispatchPtr spdDoc;
		spWB->get_Document (&spdDoc);
		if (spdDoc != NULL)
		{
			spdDoc->QueryInterface (IID_IHTMLDocument2, (void**)ppDoc);
			if (*ppDoc)
				hr = S_OK;
		}
	}
	
	return hr;
}
开发者ID:zhenyouluo,项目名称:Free-Download-Manager-vs2010,代码行数:31,代码来源:vmsDomHelper.cpp

示例3: GetObjectType

SolidEdgeConstants::ObjectType GetObjectType(IDispatchPtr pDispatch)
{
	HRESULT hr = S_OK;

	if (pDispatch != NULL)
	{
		DISPID rgDispId = 0;
		OLECHAR *Names[1] = { L"Type" };
		VARIANT varResult;
		VariantInit(&varResult);
		V_VT(&varResult) = VT_I4;
		DISPPARAMS disp = { NULL, NULL, 0, 0 };

		// Get the DISPID of the 'Type' property.
		IfFailGo(pDispatch->GetIDsOfNames(IID_NULL, Names, 1, LOCALE_USER_DEFAULT, &rgDispId));

		// Invoke the 'Type' property.
		IfFailGo(pDispatch->Invoke(rgDispId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &disp, &varResult, NULL, NULL));

		return (SolidEdgeConstants::ObjectType)(V_I4(&varResult));		
	}

Error:
	return (SolidEdgeConstants::ObjectType)0;
}
开发者ID:ADMynx,项目名称:Samples,代码行数:25,代码来源:ReportVariables.cpp

示例4: CreateCOMObject

HRESULT GenericCLRLoader::CreateCOMObject(const ATL::CString& sAssemblyFile, const ATL::CString& sAssemblyName, const ATL::CString& sTypeName, 
	IUnknown** ppIUnk, const ATL::CString& sConfigFile , const ATL::CString& sDomainName , int LocaleID )
{
	mscorlib::_ObjectHandlePtr spObjectHandle;

	HRESULT hr = GenericCLRLoader::TheInstance()->CreateObject(sAssemblyFile, sAssemblyName, sTypeName, &spObjectHandle, sConfigFile, sDomainName, LocaleID);

	if (SUCCEEDED(hr) && (spObjectHandle != NULL))
	{
		CComVariant vUnwrapped;
		spObjectHandle->Unwrap(&vUnwrapped);
		if(vUnwrapped.vt == VT_DISPATCH)
		{
			IDispatchPtr pDisp = vUnwrapped.pdispVal;
			return pDisp->QueryInterface(IID_IUnknown, (void**)ppIUnk);
		}
		if (vUnwrapped.vt == VT_UNKNOWN)
		{
			*ppIUnk = vUnwrapped.punkVal;
			(*ppIUnk)->AddRef();
			return S_OK;
		}

		return E_NOINTERFACE;
	}

	if (SUCCEEDED(hr) && spObjectHandle == NULL)
		return E_POINTER;

	return hr;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:31,代码来源:GenericCLRLoader.cpp

示例5:

HRESULT
nsScriptablePeer::GetIDispatch(IDispatch **pdisp)
{
    if (pdisp == NULL)
    {
        return E_INVALIDARG;
    }
    *pdisp = NULL;

    IUnknownPtr unk;
    HRESULT hr = mPlugin->pControlSite->GetControlUnknown(&unk);
    if (unk.GetInterfacePtr() == NULL)
    {
		return E_FAIL; 
	}

    IDispatchPtr disp = unk;
    if (disp.GetInterfacePtr() == NULL)
    { 
        return E_FAIL; 
    }

    *pdisp = disp.GetInterfacePtr();
    (*pdisp)->AddRef();

    return S_OK;
}
开发者ID:pauldorn,项目名称:v8monkey,代码行数:27,代码来源:XPConnect.cpp

示例6: STDMETHODIMP_

STDMETHODIMP_(void) CPdnWnd::NavigateComplete2(IDispatch *pDisp, VARIANT *URL)
{
	IDispatchPtr pDocDisp;
	ICustomDoc* pCustomDoc;
	m_pBrowser->get_Document(&pDocDisp);
	pDocDisp->QueryInterface(IID_ICustomDoc, (LPVOID*) &pCustomDoc);
 	HRESULT hr = 
		pCustomDoc->SetUIHandler(dynamic_cast<IDocHostUIHandler*>(this));
	pCustomDoc->Release();
}
开发者ID:chiling,项目名称:pandion,代码行数:10,代码来源:PdnWnd.cpp

示例7: typeAttr

const Interface *
Reference::findInterfaceFromDispatch (IUnknown *pUnknown)
{
    HRESULT hr;

    // See if the object implements IDispatch.
    IDispatchPtr pDispatch;
    hr = pUnknown->QueryInterface(
        IID_IDispatch, reinterpret_cast<void **>(&pDispatch));
    if (FAILED(hr)) {
        return 0;
    }

    // Ask the IDispatch interface for type information.
    unsigned count;
    hr = pDispatch->GetTypeInfoCount(&count);
    if (hr == E_NOTIMPL) {
        return 0;
    }
    if (FAILED(hr)) {
        _com_issue_error(hr);
    }
    if (count == 0) {
        return 0;
    }

    ITypeInfoPtr pTypeInfo;
    hr = pDispatch->GetTypeInfo(
        0, 
        LOCALE_USER_DEFAULT,
        &pTypeInfo);
    if (FAILED(hr)) {
        _com_issue_error(hr);
    }

    // Get the interface description.
    TypeAttr typeAttr(pTypeInfo);

    if (IsEqualIID(typeAttr->guid, __uuidof(DotNetObject))) {
        // The .NET Framework implements IDispatch::GetTypeInfo for classes
        // declared with the attribute ClassInterface(ClassInterfaceType.None)
        // by returning a description of the _Object interface.
        return 0;
    }

    const Interface *pInterface =
        InterfaceManager::instance().newInterface(typeAttr->guid, pTypeInfo);

    if (pInterface->methods().empty() && pInterface->properties().empty()) {
        // No invokable methods or properties where found in the interface
        // description.
        return 0;
    }
    return pInterface;
}
开发者ID:jbroll,项目名称:tcom,代码行数:55,代码来源:Reference.cpp

示例8: GetActiveObject

HRESULT CMObject::GetActiveObject(const CLSID clsid)
{
	HRESULT hr;
	IDispatchPtr tmpobj;
	Release();
	hr=tmpobj.GetActiveObject(clsid);
	if(SUCCEEDED(hr))
		p=tmpobj.Detach();
	return hr;

}
开发者ID:uesoft,项目名称:AutoPHS,代码行数:11,代码来源:mobject.cpp

示例9: CreateObject

HRESULT CMObject::CreateObject(const CLSID clsid)
{
	HRESULT hr;
	IDispatchPtr tmpobj;
	Release();
	hr=tmpobj.CreateInstance(clsid);
	if (SUCCEEDED(hr))
		p=tmpobj.Detach();
	return hr;

}
开发者ID:uesoft,项目名称:AutoPHS,代码行数:11,代码来源:mobject.cpp

示例10: spApplication

void TestPowerPointControllerImpl::TestNewInstance()
{	
	IDispatchPtr spApplication(_T("PowerPoint.Application"));
	assertMessage(spApplication != NULL, _T("Failed to create an instance of [PowerPoint.Application]"));

	CControllerImplPtr spImplementor(CreateImplementor());	
	spImplementor->m_bUseExistingInstance = false;
	spImplementor->Initialize();

	IDispatchPtr spHostApplication = spImplementor->GetApplication();	
	assertMessage(spHostApplication.GetInterfacePtr() != spApplication.GetInterfacePtr(), _T("CPowerPointControllerImpl::GetApplication did not create a new instance of PowerPoint."));	
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:12,代码来源:TestPowerPointControllerImpl.cpp

示例11: varID

void CNetRadioDlg::OnBnClickedTest()
{
	CString strValue;
	IHTMLDocument2* pDoc = (IHTMLDocument2*)m_Browser.GetHtmlDocument();
	HRESULT hr = S_FALSE;
	IHTMLElementCollection* pAllElem = NULL;
	IHTMLElementCollection* pAllScript = NULL;
	IHTMLElement* pElem = NULL;

	hr = pDoc->get_scripts(&pAllScript);
	if(SUCCEEDED(hr) && pAllScript != NULL)
	{
		IDispatchPtr pElemDisp = NULL;
		_variant_t varID(1);
		_variant_t varIdx(0);
		hr = pAllScript->item(varID, varIdx, &pElemDisp);
		if(SUCCEEDED(hr) && pElemDisp != NULL)
		{
			hr = pElemDisp->QueryInterface(IID_IHTMLElement,(void**)&pElem);
			if(SUCCEEDED(hr) && pElem != NULL)
			{
				BSTR bstrTagName;
				hr = pElem->get_outerHTML(&bstrTagName);
			
				hr = pElem->get_outerHTML(&bstrTagName);
				if(SUCCEEDED(hr))
				{
					CString strTagName(bstrTagName);
					SysFreeString(bstrTagName);
					MessageBox(strTagName);
				}
			}
		}
	}

	hr = pDoc->get_all(&pAllElem);

	if(SUCCEEDED(hr) && pAllElem != NULL)
	{
		IDispatchPtr pElemDisp = NULL;
		_variant_t varID(_T("body"));
		_variant_t varIdx(0);
		hr = pAllElem->item(varID, varIdx, &pElemDisp);
		if(SUCCEEDED(hr) && pElemDisp != NULL)
		{
			MessageBox(_T("OK"));
		}
	}

}
开发者ID:janker007,项目名称:cocoshun,代码行数:50,代码来源:NetRadioDlg.cpp

示例12:

bool CExcelDOMStripperStrategy::Excel2007MarkedAsFinal(IDispatchPtr spDispWorkbook)
{
	if (Excel2007(spDispWorkbook))
	{
		DISPID dispid = 0;
		LPOLESTR propertyName = L"Final";
		HRESULT hr = spDispWorkbook->GetIDsOfNames(IID_NULL, &propertyName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
		if(FAILED(hr))
		{
			std::tostringstream msg; 
			msg << _T("Failed to obtain the dispid of the [Final] property on the Workbook.") << std::ends;
			throw Workshare::Com::ComException(msg.str().c_str(), hr, spDispWorkbook);
		}

		short value = 0;
		hr = _com_dispatch_propget(spDispWorkbook, dispid, VT_BOOL, (void*)&value);
		if(FAILED(hr))
		{
			std::tostringstream msg; 
			msg << _T("Failed to obtain the [Final] property on the Workbook.") << std::ends;
			throw Workshare::Com::ComException(msg.str().c_str(), hr, spDispWorkbook);
		}
		
		if (value == -1)
			return true;
	}

	return false;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:29,代码来源:ExcelDOMStripperStrategy.cpp

示例13: ATLASSERT

bool vmsDomHelper::IsJSFunctionKnown(IHTMLDocument *pDoc, BSTR bsFuncName)
{
	ATLASSERT (pDoc != NULL);
	if (!pDoc)
		return false;
	
	IDispatchPtr spScript;
	HRESULT hr = pDoc->get_Script (&spScript);
	if (spScript == NULL)
		return false;
	
	DISPID did = NULL;
	hr = spScript->GetIDsOfNames (IID_NULL, &bsFuncName, 1, LOCALE_SYSTEM_DEFAULT, &did);

	return SUCCEEDED (hr);
}
开发者ID:zhenyouluo,项目名称:Free-Download-Manager-vs2010,代码行数:16,代码来源:vmsDomHelper.cpp

示例14: DoesMethodExistOnInterface

bool CCOMDispatchHelper::DoesMethodExistOnInterface(const IDispatchPtr& spDisp, LPCTSTR lszMethodName)
{
	USES_CONVERSION;
	DISPID rgDispId = 0;
	OLECHAR FAR* szMember = T2OLE(const_cast<LPTSTR>(lszMethodName));
	HRESULT hr = spDisp->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &rgDispId);
	return (S_OK == hr && -1 != rgDispId);
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:8,代码来源:COMDispatchHelper.cpp

示例15: spWB2

void CWebWindow::TryLoadXML()
{
	if(m_bQueryAttachXML&&m_AttachLoadXML.Length())
	{
		HRESULT hr = S_OK;
		IUnknownPtr spUnk = m_browser.GetControlUnknown();
		/////////
		// Run Script
		////////
		if(spUnk)
		{
			CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> spWB2(spUnk);
			if(spWB2)
			{
				IDispatchPtr spDispDoc = NULL;
				hr = spWB2->get_Document(&spDispDoc);
				if(spDispDoc)
				{
					CComQIPtr<IHTMLDocument, &IID_IHTMLDocument> spDoc(spDispDoc);
					if(spDoc)
					{
						IDispatchPtr spDispScript = NULL;
						hr = spDoc->get_Script(&spDispScript);
						if(spDispScript)
						{
							DISPID dispid = -1;
							OLECHAR FAR* szMember = L"LoadXML";
							hr = spDispScript->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
							if(SUCCEEDED(hr))
							{
								
								CComVariant* pvars = new CComVariant[1];
								pvars[0] = CComVariant((BSTR)m_AttachLoadXML);
								
								DISPPARAMS params = { pvars, NULL, 1, 0 };
								hr = spDispScript->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &params, NULL, NULL, NULL);
								delete []pvars;
							}
						}
					}
				}
			}
		}
	}
}
开发者ID:0anion0,项目名称:IBN,代码行数:45,代码来源:WebWindow.cpp


注:本文中的IDispatchPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。