本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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();
}
}
示例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;
};
示例11:
~GvComEventOutObserverConnection()
{
#ifdef DOREF
if (observer) observer->Release();
if (userData) userData->Release();
#endif
};
示例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;
}
示例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();
}
示例14: DoDeferredRelease
void ActiveXBrowserHost::DoDeferredRelease() const
{
assertMainThread();
IDispatch* deferred;
while (m_deferredObjects.try_pop(deferred)) {
deferred->Release();
}
}
示例15: unload
/*
* Unload a plugin.
*/
void CComPlugin::unload()
{
if (m_plugin)
{
m_plugin->Release();
m_plugin = NULL;
}
}