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


C++ IDispatch::Release方法代码示例

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


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

示例1: GetShellDispatchFromView

HRESULT GetShellDispatchFromView(IShellView *psv, REFIID riid, void **ppv)
{
    *ppv = NULL;

    IDispatch *pdispBackground;
    HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
    if (SUCCEEDED(hr))
    {
        IShellFolderViewDual *psfvd;
        hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
        if (SUCCEEDED(hr))
        {
            IDispatch *pdisp;
            hr = psfvd->get_Application(&pdisp);
            if (SUCCEEDED(hr))
            {
                hr = pdisp->QueryInterface(riid, ppv);
                pdisp->Release();
            }
            psfvd->Release();
        }
        pdispBackground->Release();
    }
    return hr;
}
开发者ID:Ippei-Murofushi,项目名称:WindowsSDK7-Samples,代码行数:25,代码来源:ExecInExplorer.cpp

示例2: AddHtmlContentToElement

//-----------------------------------------------------------------------------
// Name: AddHtmlContentToElement
// Object: 
// Parameters :
//     in  : 
//     out : 
//     return : 
//-----------------------------------------------------------------------------
BOOL CHtmlViewer::AddHtmlContentToElement(TCHAR* Id,TCHAR* Content)
{
    if (this->pIWebBrowser==NULL)
        return FALSE;

    if (!this->IsPageCompleted())
        return FALSE;

    HRESULT hr;
    BOOL bRet;
    IDispatch* pHtmlDocDispatch = NULL;
    IHTMLDocument3* pHtmlDoc = NULL;
    IHTMLElement* pElem = NULL;
    BSTR bstrElementId;

#if ((!defined(UNICODE))&& (!defined(_UNICODE)))
    WCHAR* psz;
#endif

    // get IDispatch document interface
    hr = pIWebBrowser->get_Document(&pHtmlDocDispatch);
    if (FAILED (hr) || (pHtmlDocDispatch == NULL))
        return FALSE;

    // get IHTMLDocument3 document interface
    hr = pHtmlDocDispatch->QueryInterface(IID_IHTMLDocument3,(void**)&pHtmlDoc);
    if (FAILED (hr) || (pHtmlDoc == NULL))
    {
        pHtmlDocDispatch->Release();
        return FALSE;
    }

    // get pointer to element from it's Id
#if (defined(UNICODE)||defined(_UNICODE))
    bstrElementId=SysAllocString(Id);
#else
    CAnsiUnicodeConvert::AnsiToUnicode(Id,&psz);
    bstrElementId=SysAllocString(psz);
    free(psz);    
#endif

    hr = pHtmlDoc->getElementById(bstrElementId,&pElem);
    SysFreeString(bstrElementId);
    if (FAILED (hr) || (pElem == NULL))
    {
        pHtmlDoc->Release();
        pHtmlDocDispatch->Release();
        return FALSE;
    }

    bRet=this->AddHtmlContentToElement(pElem,Content);

    pElem->Release();
    pHtmlDoc->Release();
    pHtmlDocDispatch->Release();

    return bRet;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:66,代码来源:HtmlViewer.cpp

示例3: 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

示例4: EnumEmbeds

void EnumEmbeds(IHTMLDocument2 *pIHTMLDocument2)
{
	if(!pIHTMLDocument2) return;

	HRESULT hr;
	USES_CONVERSION;

	CComPtr< IHTMLElementCollection > spEmbedCollection;
	hr = pIHTMLDocument2->get_embeds(&spEmbedCollection);	//取得Embed的集合
	if (FAILED(hr))
	{
		cout << _T("错误: 获取Embed集合IHTMLElementCollection!") << endl;
		return;
	}

	long nEmbedCount = 0;				//取得Embed个数
	hr = spEmbedCollection->get_length(&nEmbedCount);
	if (FAILED(hr))
	{
		cout << _T("错误: 获取Embed集合IHTMLElementCollection的长度!") << endl;
	}

	cout << "Embed对象共: " << nEmbedCount << endl;

	CComBSTR bstrPluginsPage, bstrSrc;
	IDispatch *pDisp = NULL;
	CComQIPtr< IHTMLEmbedElement > spEmbedElement;
	for(long i = 0; i < nEmbedCount; i++)
	{
		hr = spEmbedCollection->item(CComVariant(i), CComVariant(), &pDisp);
		if (FAILED(hr) || !pDisp) continue;

		spEmbedElement = pDisp;
		pDisp->Release();
		
		spEmbedElement->get_pluginspage(&bstrPluginsPage);
		spEmbedElement->get_src(&bstrSrc);
		cout << i + 1
			<< ": pluginspage = " << (bstrPluginsPage ? OLE2CT(bstrPluginsPage) : _T(""))
			<< ", src = " << (bstrSrc ? OLE2CT(bstrSrc) : _T("")) 
			<< endl;
	}
	if (pDisp) 
	{
		pDisp->Release();
		pDisp = NULL;
	}
}
开发者ID:harrysun2006,项目名称:07_UltraSpy,代码行数:48,代码来源:IEHelper.cpp

示例5: UpdatePlotRange

//May be new points have been added to the plot data source. Update plot range
BOOL CXLAutomation::UpdatePlotRange(int nYColumn)
{
	if((NULL == m_pdispWorksheet) || (NULL == m_pdispWorkbook) || (NULL == m_pdispActiveChart))
		return FALSE;

	VARIANTARG varg1;
	IDispatch *pdispRange = NULL;
	IDispatch *pdispActiveChart = NULL;
	BOOL bResult = TRUE;
	
	ClearAllArgs();
	AddArgumentDouble(NULL, 0, nYColumn);
	if (!ExlInvoke(m_pdispWorksheet, L"Columns", &varg1, DISPATCH_PROPERTYGET, DISP_FREEARGS))
		return FALSE;
	pdispRange = varg1.pdispVal;

   //ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A:A, B:B"), PlotBy:= _
   //    xlColumns
	ClearAllArgs();
	AddArgumentInt2(L"PlotBy", 0, xlColumns);
	AddArgumentDispatch(L"Source", 0, pdispRange);	// will auto-free
	pdispRange = NULL;
	if (!ExlInvoke(m_pdispActiveChart, L"SetSourceData", NULL, DISPATCH_METHOD, DISP_FREEARGS))
		bResult = FALSE;

	ClearAllArgs();
	if(NULL != pdispRange)
	{
		pdispRange->Release();
		pdispRange = NULL;
	}
	
	return bResult;
	
}
开发者ID:epapatzikou,项目名称:nexta,代码行数:36,代码来源:XLAutomation.cpp

示例6: ProcessElementCollection

void CIncrementSystemBFDlg::ProcessElementCollection(IHTMLElementCollection* pElemColl, CString id)
{	
	IDispatch* pElemDisp = NULL;
	IHTMLElement* pElem = NULL;
	VARIANT vID;
	VARIANT vIdx;

	VariantInit(&vID);
	vID.vt=VT_BSTR;
	vID.bstrVal=_bstr_t(id);

	VariantInit(&vIdx);
			  
	vIdx.vt=VT_I4;
	vIdx.lVal=0;

	HRESULT hr = pElemColl->item( vID, vIdx, &pElemDisp );
	if ( SUCCEEDED(hr) && pElemDisp != 0x0)
	{
		hr = pElemDisp->QueryInterface( IID_IHTMLElement, (void**)&pElem );
		if ( SUCCEEDED(hr) )
		{
			// Obtained element with ID of "myID".
			BSTR bsHtml;
			pElem->get_outerHTML(&bsHtml);
			CLogFile::WriteLog(bsHtml);

			ConnectButton1( pElem );
			pElem->Release();	
		}
		pElemDisp->Release();
	}
	pElemColl->Release();
}
开发者ID:hucigang,项目名称:IncrementSystemBF,代码行数:34,代码来源:IncrementSystemBFDlg.cpp

示例7:

STDMETHODIMP CompositeOverlayImpl<B>::put_Overlays(LPSAFEARRAY newVal)
{
	ClearAndDestroy();
	long lb = 0;
	long ub = 0;
	if( !(newVal->fFeatures & FADF_DISPATCH) )
		return E_INVALIDARG;

	HRESULT hr = ::SafeArrayGetUBound(newVal, 1, &ub);
	hr = ::SafeArrayGetLBound(newVal, 1, &lb);

	IDispatch *pDisp;
	IOverlay *pOverlay;
	long indices[1];
	for (int i=lb; i<=ub; i++)
	{
		indices[0] = i;
		pDisp = 0;
		::SafeArrayGetElement(newVal, indices, &pDisp);
		if (pDisp)
		{
			if (SUCCEEDED(pDisp->QueryInterface(__uuidof(IOverlay), (void**)&pOverlay)))
			{
				AtlTrace("Added overlay to composite\n");
				Add(pOverlay);
				pOverlay->Release();
			}
			pDisp->Release();
		}
	}

	return S_OK;
}
开发者ID:Templier,项目名称:desktopx,代码行数:33,代码来源:CompositeOverlayImpl.cpp

示例8: PyCom_BuildPyException

// @pymethod |PyIDocHostUIHandler|ShowContextMenu|Description of ShowContextMenu.
PyObject *PyIDocHostUIHandler::ShowContextMenu(PyObject *self, PyObject *args)
{
	IDocHostUIHandler *pIDHUIH = GetI(self);
	if ( pIDHUIH == NULL )
		return NULL;
	// @pyparm int|dwID||Description for dwID
	POINT pt;
	// @pyparm (int, int)|pt||Description for ppt
	// @pyparm <o PyIUnknown>|pcmdtReserved||Description for pcmdtReserved
	// @pyparm <o PyIDispatch>|pdispReserved||Description for pdispReserved
	PyObject *obpcmdtReserved;
	PyObject *obpdispReserved;
	DWORD dwID;
	IUnknown * pcmdtReserved;
	IDispatch * pdispReserved;
	if ( !PyArg_ParseTuple(args, "l(ii)OO:ShowContextMenu", &dwID, &pt.x, &pt.y,
			       &obpcmdtReserved, &obpdispReserved) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpcmdtReserved, IID_IUnknown, (void **)&pcmdtReserved, TRUE /* bNoneOK */))
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpdispReserved, IID_IDispatch, (void **)&pdispReserved, TRUE /* bNoneOK */)) {
		if (pcmdtReserved) pcmdtReserved->Release();
		return NULL;
	}
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDHUIH->ShowContextMenu( dwID, &pt, pcmdtReserved, pdispReserved );
	if (pcmdtReserved) pcmdtReserved->Release();
	if (pdispReserved) pdispReserved->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler );
	return PyInt_FromLong(hr);
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:36,代码来源:PyIDocHostUIHandler.cpp

示例9: HideScrollBar

void CHtmlViewNotice::HideScrollBar()
{
	IDispatch *pDisp = GetHtmlDocument();
	if( pDisp != NULL )
	{
		IHTMLDocument2* pHTMLDocument2;

		HRESULT hr;
		hr = pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDocument2);

		if( hr == S_OK )
		{
			IHTMLElement *pIElement;

			hr = pHTMLDocument2->get_body(&pIElement);

			if( pIElement )
			{
				IHTMLBodyElement *pIBodyElement;

				hr = pIElement->QueryInterface(IID_IHTMLBodyElement,(void**)&pIBodyElement);

				pIBodyElement->put_scroll(L"no");
				pIBodyElement->Release();
			}
		}

		pHTMLDocument2->Release();
		pDisp->Release();
	}
}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:31,代码来源:HtmlViewNotice.cpp

示例10: GetSelObject

static wxAutoOleInterface<IHTMLSelectionObject> GetSelObject(IOleObject *oleObject)
{
    // Query for IWebBrowser interface
    wxAutoOleInterface<IWebBrowser2> wb(IID_IWebBrowser2, oleObject);
    if (! wb.Ok())
        return wxAutoOleInterface<IHTMLSelectionObject>();

    IDispatch *iDisp = NULL;
    HRESULT hr = wb->get_Document(&iDisp);
    if (hr != S_OK)
        return wxAutoOleInterface<IHTMLSelectionObject>();

    // Query for Document Interface
    wxAutoOleInterface<IHTMLDocument2> hd(IID_IHTMLDocument2, iDisp);
    iDisp->Release();

    if (! hd.Ok())
        return wxAutoOleInterface<IHTMLSelectionObject>();

    IHTMLSelectionObject *_so = NULL;
    hr = hd->get_selection(&_so);

    // take ownership of selection object
    wxAutoOleInterface<IHTMLSelectionObject> so(_so);

    return so;
};
开发者ID:2015E8007361074,项目名称:wxPython,代码行数:27,代码来源:IEHtmlWin.cpp

示例11:

    ~GvComEventOutObserverConnection()
	{	
#ifdef DOREF
		if (observer) observer->Release();
		if (userData) userData->Release();
#endif
	};
开发者ID:deepmatrix,项目名称:blaxxun-cc3d,代码行数:7,代码来源:gvfield.cpp

示例12: AddDefaultScriptItem

BOOL CScriptMeterImpl::AddDefaultScriptItem()
{
	HRESULT hr;
	hr = scriptPtr->AddTypeLib(LIBID_COMMETERSLib, 1, 0, 0);

	if (!SUCCEEDED(hr))
		return false;

	BOOL ret = AddScriptItem(ACTIVESCRIPT_HOST_NAME, (IMeter*)this);
#ifdef CONNECTABLE
	IDispatch *pDispatch;
	scriptPtr->GetScriptDispatch(NULL, &pDispatch);
	pDispatch->Release();
	pUtils->put_Script(pDispatch);
	pUtils->put_ScriptHost(this);

	AddScriptItem(UTILS_NAME, pUtils, SCRIPTITEM_ISVISIBLE);
#endif

	IClientModel *_model = 0;
	get_Model(&_model);
	if (_model)
	{
		ret = AddScriptItem(MODEL_NAME, _model, SCRIPTITEM_ISVISIBLE | MY_SCRIPTITEM_WEAK);
		model->Release();
	}
	else
		AtlTrace("Model is not set in ScriptMeterImpl\n");

	return ret;
}
开发者ID:Templier,项目名称:desktopx,代码行数:31,代码来源:ScriptMeterImpl.cpp

示例13: main

int main(void)
{
   // Initialize COM for this thread...
   CoInitialize(NULL);

   // Get CLSID for our server...
   CLSID clsid;
   HRESULT hr = CLSIDFromProgID(L"bibleworks.automation", &clsid);

   if(FAILED(hr)) {
      ::MessageBox(NULL, "CLSIDFromProgID() failed", "Error", 0x10010);
      return -1;
   }

   // Start server and get IDispatch...
   IDispatch *pBwApp;
   hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&pBwApp);
   if(FAILED(hr)) {
      ::MessageBox(NULL, "Bibleworks not registered properly", "Error", 0x10010);
      return -2;
   }

   // Tell Bibleworks not to quit. By the way, if you tell it TO quit, it behaves
   // very strangely.
//   {
//      VARIANT x;
//      x.vt = VT_I4;
//      x.lVal = 0; // set AutoQuit to false = 0
//	  AutoWrap(DISPATCH_METHOD, NULL, pBwApp, (wchar_t*)L"AutoQuit", 1, x);
//   }

   // Go to verse
   {
      VARIANT parm;
      parm.vt = VT_BSTR;
	  // Following is the correct way to do this with a string literal, but we won't be
	  // able to use this method in Bibledit
      //parm.bstrVal = ::SysAllocString(L"Luke 14:1");
	  ustring searchstring("Isa 15 1");
	  
	  // This code doesn't result in a memory error or leak.
	  std::wstring wide_string( searchstring.begin(), searchstring.end() );
	  parm.bstrVal = ::SysAllocString(wide_string.c_str()); // this allocates memory, which is freed below

      VARIANT result;
      VariantInit(&result);
      AutoWrap(DISPATCH_METHOD, &result, pBwApp, (wchar_t*)L"GoToVerse", 1, parm);
      VariantClear(&parm); // this will free the memory associated with parm.bstrVal string
   }

   // Wait for user...
   ::MessageBox(NULL, "All done.", "Notice", 0x10000);

   // Release references...
   pBwApp->Release();

   // Uninitialize COM for this thread...
   CoUninitialize();
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:59,代码来源:bibleworksole.cpp

示例14: DoDeferredRelease

void ActiveXBrowserHost::DoDeferredRelease() const
{
    assertMainThread();
    IDispatch* deferred;
    while (m_deferredObjects.try_pop(deferred)) {
        deferred->Release();
    }
}
开发者ID:leeight,项目名称:FireBreath,代码行数:8,代码来源:ActiveXBrowserHost.cpp

示例15: unload

/*
 * Unload a plugin.
 */
void CComPlugin::unload()
{
    if (m_plugin)
    {
        m_plugin->Release();
        m_plugin = NULL;
    }
}
开发者ID:Nalatroz,项目名称:trans3,代码行数:11,代码来源:plugins.cpp


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