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


C++ IDispatch类代码示例

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


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

示例1: DocumentCompleteExplorerSelectItem

void CIncrementSystemBFDlg::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL) 
{
	DocumentCompleteExplorerSelectItem(pDisp, URL);
	// TODO: Add your control notification handler code here
	IDispatch * pDocDisp = NULL;
   
	// get the DOM
	IHTMLDocument2  *pDoc=NULL;
	pDocDisp = m_MyIE.GetDocument(); 
   
	if (pDocDisp != NULL) 
	{
      // Obtained the document object by specifying the IHTMLDocument2 Interface.
		HRESULT hr= pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );
		
		IHTMLElement* pBody = NULL;
		BSTR bstrBody;
		pDoc->get_body(&pBody);

		pBody->get_innerHTML(&bstrBody);

		if ( SUCCEEDED(hr) )
		{
			// Obtained the IHTMLDocument2 interface for the document object
			IHTMLElementCollection* pElemColl = NULL;
			hr = pDoc->get_all( &pElemColl );
			if ( SUCCEEDED(hr) )//ec
			{
				CComDispatchDriver spScript; 
				pDoc->get_Script(&spScript);  
				CComVariant var(static_cast<IDispatch*>(new CMyEventSink));  
				//spScript.Invoke1(L"SaveCppObject", &var); 
				// Obtained element collection.
				/*
#define LOGON_HTML_ID _T("Logon")
#define HTTP1_HTML_ID _T("Http1")
#define AUTH_HTML_ID _T("Authentication")
#define QUERYPT_HTML_ID _T("QueryPhoneType")
#define QUERYPOP_HTML_ID _T("QueryPopup")
#define QUERYPHONE_HTML_ID _T("QueryPhone")
#define HB_HTML_ID _T("Heartbeat")
#define RESETPWD_HTML_ID _T("ResetPassword")
#define LOGOFF_HTML_ID _T("Logoff")
				*/
				// buttonChangePassword   querySerialNumber
				
				ProcessElementCollection( pElemColl, "querySerialNumber");
			}
		}
		//ProcessDocument( pDocDisp );
	}
	pDocDisp->Release();
}
开发者ID:hucigang,项目名称:IncrementSystemBF,代码行数:53,代码来源:IncrementSystemBFDlg.cpp

示例2: GetDoc

//taken from http://www.wischik.com/lu/programmer/webform.html
IHTMLElement* TextRenderBrain::GetElementFromId(string id_str, const GUID *iid)
{
	const char* id = NULL;
	IHTMLElement *ret=0; 
	IHTMLElementCollection* doc_all = NULL;
	IHTMLDocument2 *doc = NULL; 
	HRESULT hr;

	if (id_str.size() == 0) return 0;
	
	id = id_str.c_str();
	doc = GetDoc();

	if (doc==0) return 0;
	hr = doc->get_all(&doc_all);      // this is like doing document.all
  
	if (hr == S_OK)
	{ 
		IDispatch* disp = NULL;
		VARIANT vid;
		VARIANT v0; 
		unsigned int len;
		wchar_t* ws = NULL;

		VariantInit(&v0);
		len=strlen(id);
		vid.vt=VT_BSTR;
    
		ws = new wchar_t[len+1];
		MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, id, -1, ws, len+1);
		vid.bstrVal=ws;

		hr = doc_all->item(vid,v0,&disp);       // this is like doing document.all["messages"]
		delete[] ws;

		//We may be leaking a small amount of memory here because this crashes:
		//SysFreeString(vid.bstrVal);
		
		if (hr == S_OK && disp != 0)
		{ 
			IHTMLElement* element = NULL;

			if (iid == 0) hr = disp->QueryInterface(IID_IHTMLElement,(void **)&element);
			else hr = disp->QueryInterface(*iid,(void**)&element);
      
			if (hr == S_OK) ret = element; // it's the caller's responsibility to release it
			disp->Release();
		}
		doc_all->Release();
	}
	doc->Release();
	return ret;
}
开发者ID:daisy,项目名称:amis,代码行数:54,代码来源:TextRenderBrain.cpp

示例3: invoke

void HostTimerDispatcher::invoke(UINT timerId)
{
	IDispatch * pDisp = NULL;
	if (!m_timerDispatchMap.query(timerId, pDisp) || !pDisp)
		return;

	VARIANTARG args[1];
	args[0].vt = VT_I4;
	args[0].lVal = timerId;
	DISPPARAMS dispParams = { args, NULL, _countof(args), 0 };
	pDisp->Invoke(DISPID_VALUE, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParams, NULL, NULL, NULL);
}
开发者ID:leefan,项目名称:foo-jscript-panel,代码行数:12,代码来源:host_timer_dispatcher.cpp

示例4: CpiGetCatalogCollection

HRESULT CpiGetCatalogCollection(
    ICatalogCollection* piColl,
    ICatalogObject* piObj,
    LPCWSTR pwzName,
    ICatalogCollection** ppiColl
    )
{
    HRESULT hr = S_OK;

    ICOMAdminCatalog* piCatalog = NULL;
    IDispatch* piDisp = NULL;

    BSTR bstrName = NULL;

    VARIANT vtKey;
    ::VariantInit(&vtKey);

    // copy name string
    bstrName = ::SysAllocString(pwzName);
    ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "Failed to allocate BSTR for collection name");

    // get catalog
    hr = CpiGetAdminCatalog(&piCatalog);
    ExitOnFailure(hr, "Failed to get COM+ admin catalog");

    // get key
    hr = piObj->get_Key(&vtKey);
    ExitOnFailure(hr, "Failed to get object key");

    // get collecton from catalog
    hr = piColl->GetCollection(bstrName, vtKey, &piDisp);
    ExitOnFailure(hr, "Failed to get collection");

    hr = piDisp->QueryInterface(IID_ICatalogCollection, (void**)ppiColl);
    ExitOnFailure(hr, "Failed to get IID_ICatalogCollection interface");

    // populate collection
    hr = (*ppiColl)->Populate();
    if (COMADMIN_E_OBJECTERRORS == hr)
        CpiLogCatalogErrorInfo();
    ExitOnFailure(hr, "Failed to populate collection");

    hr = S_OK;

LExit:
    // clean up
    ReleaseObject(piCatalog);
    ReleaseObject(piDisp);
    ReleaseBSTR(bstrName);
    ::VariantClear(&vtKey);

    return hr;
}
开发者ID:BMurri,项目名称:wix3,代码行数:53,代码来源:cputilexec.cpp

示例5: getDocument

void IEView::clear(IEVIEWEVENT *event) {
#ifdef GECKO
//    pWebBrowser->Navigate(L"www.onet.pl", NULL, NULL, NULL, NULL);
  //  return;
#endif
	IHTMLDocument2 *document = getDocument();
	if (document == NULL) {
		pWebBrowser->Navigate(L"about:blank", NULL, NULL, NULL, NULL);
		HRESULT hr = S_OK;
		IHTMLDocument2 *document = NULL;
		while ((document == NULL) && (hr == S_OK)) {
			Sleep(0);
			IDispatch *dispatch = NULL;
			if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && (dispatch != NULL)) {
				hr = dispatch->QueryInterface(IID_IHTMLDocument2, (void **)&document);
				dispatch->Release();
			}
		}
		if (document != NULL) {
			document->Release();
		}
	} else {
		document->close();
		VARIANT		open_name;
		VARIANT		open_features;
		VARIANT		open_replace;
		IDispatch	*open_window	= NULL;
		VariantInit(&open_name);
		open_name.vt      = VT_BSTR;
		open_name.bstrVal = SysAllocString(L"_self");
		VariantInit(&open_features);
		VariantInit(&open_replace);

		HRESULT hr = document->open(SysAllocString(L"text/html"),
		                    open_name,
			                    open_features,
			                    open_replace,
			                    &open_window);
		if (hr == S_OK) {
		//	pWebBrowser->Refresh();
		}
		if (open_window != NULL) {
			open_window->Release();
		}
		document->Release();
	}
	if (builder!=NULL) {
		builder->clear(this, event);
	}
	clearRequired = false;
	getFocus = false;
}
开发者ID:BackupTheBerlios,项目名称:mgoodies-svn,代码行数:52,代码来源:IEView.cpp

示例6: ObjGet

BOOL 
Foobar::COM_ConnectServer()
{
	HRESULT hr;
	/***** Attach to the running COM instance... *****/
	IDispatch	*pDisp = NULL;
	if(m_comAppH) {
		//try Foobar COMServer2Helper (fast way)
		CALL( m_comAppH->get_Server(&pDisp));
		hr = pDisp->QueryInterface(__uuidof(m_comApp), (void**)&m_comApp);
		RELEASE(pDisp,TRUE);
	}
	else {
		//try GetActive Foobar Object (COMServer2Helper.exe not install right)
		CALL( ObjGet(CLSID_Application07, __uuidof(m_comApp), (void**)&m_comApp));
	}
	if(SUCCEEDED(hr)) {
		DEBUGOUT("Foobar:\t\tServer = ","on");
		// ***** get the Fooar Playback interface...    *****
		CALL( m_comApp->get_Playback(&m_comPlayback) );
		if (m_comPlayback == NULL)
			goto FAILURE;
		// ***** Instantiate an IMIM_fooEventS object. *****
		if(m_comPlaybackEventSink = new IMIM_fooEventS(*this, m_comPlayback, &Foobar::COM_OnEventInvoke)) {

			VARIANT_BOOL bState = VARIANT_FALSE;
			m_comPlayback->get_IsPlaying(&bState);

			m_state = (bState == VARIANT_TRUE) ? PL_PLAYING : PL_STOPPED;
			if(SetActivePlayer(m_index, m_index))
				NotifyInfoChanged();
		}
	}
	else {
		DEBUGOUT("Foobar:\t\tServer = ","off");
		RELEASE(pDisp,TRUE);
		m_state = PL_OFFLINE;
		return FALSE;
	}
	return TRUE;

FAILURE:
  #ifdef DEBUG
	_com_error err(hr);
	OutputDebugString(_T("Foobar:\t\tERROR = COM_ConnectServer()\n\t\t\t"));
	OutputDebugString(err.ErrorMessage());
	OutputDebugString(_T("\n)"));
  #endif
	RELEASE(pDisp,TRUE);
	COM_ReleaseServer();
	return FALSE;
}
开发者ID:TonyAlloa,项目名称:miranda-dev,代码行数:52,代码来源:foobar.cpp

示例7:

IWebBrowser * CIECoreView::GetGlobalWebBrowser(void)
{
	if ( m_dwCookie == 0 )
	{
		spGIT->RegisterInterfaceInGlobal(GetApplication(),IID_IDispatch,&m_dwCookie);
	}

 	IDispatch *pDisp;
 	spGIT->GetInterfaceFromGlobal(m_dwCookie,IID_IDispatch,(void **)&pDisp);
 	IWebBrowser *pWb = NULL;
 	pDisp->QueryInterface(IID_IWebBrowser,(void **)&pWb);
 	return pWb;
}
开发者ID:gaozan198912,项目名称:myproject,代码行数:13,代码来源:IECoreView.cpp

示例8: DisconnectObjects

HRESULT STDMETHODCALLTYPE CRubyScript::DisconnectObjects( void)
{
	for (OleObjListIter itole = m_listOleObj.begin(); itole != m_listOleObj.end(); itole++)
	{
		IDispatch* p = (*itole)->pDispatch;
		if (p) 
		{
			p->Release();
			(*itole)->pDispatch = NULL;
		}
	}
	m_listOleObj.clear();
	return S_OK;
}
开发者ID:arton,项目名称:RScript20,代码行数:14,代码来源:RubyScript.cpp

示例9: qAxFactory

QT_BEGIN_NAMESPACE

QAxBase *qax_create_object_wrapper(QObject *object)
{
    IDispatch *dispatch = 0;
    QAxObject *wrapper = 0;
    qAxFactory()->createObjectWrapper(object, &dispatch);
    if (dispatch) {
        wrapper = new QAxObject(dispatch, object);
        wrapper->setObjectName(object->objectName());
        dispatch->Release();
    }
    return wrapper;
}
开发者ID:RS102839,项目名称:qt,代码行数:14,代码来源:qaxscriptwrapper.cpp

示例10: ResultSrc

HRESULT CISEStdPriceProvider::OnQuoteUpdate(const CComVariant &varParams,const  CComVariant &varResults)
{
	CComVariant varResult;
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[2];
	int nConnections = m_vec.GetSize();
	HRESULT hr = S_OK;
		
    CComVariant _varResults;

    _ISEQuoteUpdateResult ResultSrc(varResults);
    _QuoteUpdateResult ResultDest;
	ResultDest.Init();

	ResultDest->UpdateDateTime = 0;
	ResultDest->SeqNum = 0;
	ResultDest->BidPrice = ResultSrc->BidPrice;
	ResultDest->AskPrice = ResultSrc->AskPrice;
	ResultDest->BidSize = ResultSrc->BidSize;
	ResultDest->AskSize = ResultSrc->AskSize;
	ResultDest->Currency = SysAllocString(ResultSrc->Currency);
	ResultDest->LotSize = 0;
	ResultDest->LastPrice = ResultSrc->LastPrice;
	ResultDest->OpenInterest = 0;
	ResultDest->Volume = 0;
	ResultDest->Exchange = 0;

    ResultDest.CopyTo(_varResults);

	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			VariantClear(&varResult);
			pvars[1] = varParams;
			pvars[0] = _varResults;
			DISPPARAMS disp = { pvars, NULL, 2, 0 };
			hr = pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
		}
	}
	delete[] pvars;

	if(FAILED(hr)) return hr;

	return varResult.scode;
}
开发者ID:AlexS2172,项目名称:IVRM,代码行数:50,代码来源:isestdpriceprovider.cpp

示例11: CreateWorkSheet

//Create an empty workshet
BOOL CXLAutomation::CreateWorkSheet()
{
	if(NULL == m_pdispExcelApp)
		return FALSE;

	BOOL fResult;
	VARIANTARG varg1, varg2;
	IDispatch *pdispRange = NULL;
	IDispatch *pdispActiveSheet = NULL;
	IDispatch *pdispActiveCell = NULL;
	IDispatch *pdispCrt = NULL;
	

	
	// Set wb = [application].Workbooks.Add(template := xlWorksheet)
	ClearAllArgs();
	if (!ExlInvoke(m_pdispExcelApp, L"Workbooks", &varg1, DISPATCH_PROPERTYGET, 0))
		return FALSE;
	
	
	ClearAllArgs();
	AddArgumentInt2(L"Template", 0, xlWorksheet);
	fResult = ExlInvoke(varg1.pdispVal, L"Add", &varg2, DISPATCH_METHOD, 0);
	ReleaseVariant(&varg1);
	if (!fResult)
		return FALSE;
	m_pdispWorkbook = varg2.pdispVal;
	
	// Set ws = wb.Worksheets(1)
	ClearAllArgs();
	AddArgumentInt2(NULL, 0, 1);
	if (!ExlInvoke(m_pdispWorkbook, L"Worksheets", &varg2, DISPATCH_PROPERTYGET, 0))
		goto CreateWsBail;
	m_pdispWorksheet = varg2.pdispVal;

	fResult = TRUE;

CreateWsExit:
	
	if (pdispRange != NULL)
		pdispRange->Release();
	if (pdispCrt != NULL)
		pdispCrt->Release();
	return fResult;
	
CreateWsBail:
	fResult = FALSE;
	goto CreateWsExit;

}
开发者ID:epapatzikou,项目名称:nexta,代码行数:51,代码来源:XLAutomation.cpp

示例12: var_array

HRESULT AccessibleObject::BuildChildren(std::vector<AccessibleChild>& children,
                                        IAccessible* acc, LPARAM param) {
  if (acc == nullptr)
    acc = acc_;
  if (acc == nullptr)
    return E_INVALIDARG;

  long child_count = 0;
  HRESULT hr = acc->get_accChildCount(&child_count);

  if (FAILED(hr))
    return hr;
  if (child_count == 0)
    return S_FALSE;

  long obtained_count = 0;
  std::vector<VARIANT> var_array(child_count);
  hr = AccessibleChildren(acc, 0L, child_count, var_array.data(),
                          &obtained_count);

  if (FAILED(hr))
    return hr;

  children.resize(obtained_count);
  for (int i = 0; i < obtained_count; i++) {
    VARIANT var_child = var_array[i];

    if (var_child.vt == VT_DISPATCH) {
      IDispatch* dispatch = var_child.pdispVal;
      IAccessible* child = nullptr;
      hr = dispatch->QueryInterface(IID_IAccessible, (void**)&child);
      if (hr == S_OK) {
        GetName(children.at(i).name, CHILDID_SELF, child);
        GetRole(children.at(i).role, CHILDID_SELF, child);
        GetValue(children.at(i).value, CHILDID_SELF, child);
        if (AllowChildTraverse(children.at(i), param))
          BuildChildren(children.at(i).children, child, param);
        child->Release();
      }
      dispatch->Release();

    } else {
      GetName(children.at(i).name, var_child.lVal, acc);
      GetRole(children.at(i).role, var_child.lVal, acc);
      GetValue(children.at(i).value, var_child.lVal, acc);
    }
  }

  return S_OK;
}
开发者ID:Hydro8182,项目名称:taiga,代码行数:50,代码来源:win_accessibility.cpp

示例13: insertBefore

void ExplorerElement::insertBefore(AbstractWebElement* element,
		AbstractWebElement* before) {
	ExplorerElement* child = dynamic_cast<ExplorerElement*> (element);
	ExplorerElement* sibling = dynamic_cast<ExplorerElement*> (before);
	if (child == NULL)
		return;
	IHTMLDOMNode *e;
	HRESULT hr = m_pElement->QueryInterface(IID_IHTMLDOMNode, reinterpret_cast<void**>(&e));
	if (!FAILED(hr) && e != NULL)
	{
		IHTMLDOMNode *e2;
		HRESULT hr = child->m_pElement->QueryInterface(IID_IHTMLDOMNode, reinterpret_cast<void**>(&e2));
		if (!FAILED(hr) && e2 != NULL)
		{
			VARIANT v;
			v.pdispVal = NULL;
			if (sibling == NULL)
			{
				v.vt = VT_NULL;
			}
			else
			{
				// hr = sibling->m_pElement->QueryInterface(IID_IHTMLDOMNode, reinterpret_cast<void**>(&v.pdispVal));
				v.vt = VT_DISPATCH;
				v.pdispVal = sibling->m_pElement;
			}
			if (!FAILED(hr))
			{
				IHTMLDOMNode *e4 = NULL;
				hr = e->insertBefore(e2, v, &e4);
				if (e4 != NULL) {
					IDispatch *old = child->m_pElement;
					HRESULT hr = e4->QueryInterface(IID_IDispatch, reinterpret_cast<void**>(&child->m_pElement));
					if (!FAILED(hr))
					{
						old->Release();
					}
					else
					{
						child->m_pElement = old;
					}
					e4->Release();
				}
			}
			e2->Release();
		}
		e->Release();
	}
}
开发者ID:SoffidIAM,项目名称:esso,代码行数:49,代码来源:ExplorerElement.cpp

示例14: GetMainMenu

void CRunView::ShowPictureComplete(LPCTSTR lpszPicture)
{
	IDispatch* pMenuObject = GetMainMenu();

	if (pMenuObject != NULL)
	{
		m_arrAccels.RemoveAll();

		if (m_menu.m_hMenu != NULL)
			m_menu.DestroyMenu();

		m_menu.CreateMenu();
		
		CComQIPtr<IDrawMenu, &IID_IDrawMenu> spDrawMenu(pMenuObject);
		long lCount;
		spDrawMenu->get_ItemCount(&lCount);
		
		int nIndex = 0;
		AddMenuItems(m_menu.m_hMenu, spDrawMenu, nIndex, lCount, 0);
		
		if (m_pMenu == NULL)
		{
			CMenu* pMenu = AfxGetMainWnd()->GetMenu();
			if (pMenu != NULL)
				m_hAltMenu = pMenu->GetSafeHmenu();
		}

		AfxGetMainWnd()->SetMenu(&m_menu);
		
		m_pMenu = spDrawMenu;

		m_bLockMenu = FALSE;
	
		pMenuObject->Release();

		if (m_arrAccels.GetSize() > 0)
			m_hAccelTable = CreateAcceleratorTable(m_arrAccels.GetData(), m_arrAccels.GetSize());
	}
	else
	{
		if (m_pMenu != NULL)
		{
			::SetMenu(AfxGetMainWnd()->GetSafeHwnd(), m_hAltMenu);
			
			m_hAltMenu = NULL;
			m_pMenu = NULL;
		}
	}
}
开发者ID:JackWangCUMT,项目名称:SuperCxHMI,代码行数:49,代码来源:RunView.cpp

示例15: GetI

// @pymethod int|PyIDispatch|GetTypeInfoCount|Retrieves the number of <o PyITypeInfo>s the object provides.
PyObject *PyIDispatch::GetTypeInfoCount(PyObject *self, PyObject *args)
{
	if (!PyArg_ParseTuple(args,":GetTypeInfoCount"))
		return NULL;
	unsigned int ret;

	IDispatch *pMyDispatch = GetI(self);
	if (pMyDispatch==NULL) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pMyDispatch->GetTypeInfoCount(&ret);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pMyDispatch, IID_IDispatch);
	return Py_BuildValue("i", ret);
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:16,代码来源:PyIDispatch.cpp


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