本文整理汇总了C++中LPDISPATCH::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDISPATCH::Release方法的具体用法?C++ LPDISPATCH::Release怎么用?C++ LPDISPATCH::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDISPATCH
的用法示例。
在下文中一共展示了LPDISPATCH::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecCommand
//OLECMDID_PRINT = 6,
HRESULT CWtlHtmlView::ExecCommand( OLECMDID nCmdID, OLECMDEXECOPT nCmdExecOpt, VARIANTARG* pvarargIn, VARIANTARG* pvarargOut)
{
HRESULT hr=S_OK;
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
try {
m_spWebBrowser2->get_Document(&lpDispatch);
if(lpDispatch==NULL)
throw;
OLECMDF eQuery ; // 'return value type for QueryStatusWB
if(FAILED( m_spWebBrowser2->QueryStatusWB(OLECMDID_PRINT, &eQuery))) // 'get print command status
throw;
if(!( eQuery & OLECMDF_ENABLED) )
throw;
lpDispatch->QueryInterface(IID_IOleCommandTarget, (void**)&lpOleCommandTarget);
if(lpOleCommandTarget==NULL)
throw;
// Print contents of WebBrowser control.
hr=lpOleCommandTarget->Exec(NULL, nCmdID, nCmdExecOpt, pvarargIn, pvarargOut);
}
catch(...)
{
hr=E_FAIL;
}
if(lpDispatch)
lpDispatch->Release();
if(lpOleCommandTarget)
lpOleCommandTarget->Release();
return hr;
}
示例2: strchr
/* Toggle a button and return the new state. */
static void
toggle_button (LPDISPATCH button, const char *tag, int instid)
{
int state;
char tag2[256];
char *p;
LPDISPATCH inspector;
inspector = get_inspector_from_instid (instid);
if (!inspector)
{
log_debug ("%s:%s: inspector not found", SRCNAME, __func__);
return;
}
state = get_oom_int (button, "State");
log_debug ("%s:%s: button `%s' state is %d", SRCNAME, __func__, tag, state);
state = (state == msoButtonUp)? msoButtonDown : msoButtonUp;
put_oom_int (button, "State", state);
/* Toggle the other button. */
mem2str (tag2, tag, sizeof tag2 - 2);
p = strchr (tag2, '#');
if (p)
*p = 0; /* Strip the instance id suffix. */
if (*tag2 && tag2[1] && !strcmp (tag2+strlen(tag2)-2, "@t"))
tag2[strlen(tag2)-2] = 0; /* Remove the "@t". */
else
strcat (tag2, "@t"); /* Append a "@t". */
log_debug ("%s:%s: setting `%s' state to %d", SRCNAME, __func__, tag2, state);
set_one_button (inspector, tag2, state);
inspector->Release ();
}
示例3: ExecuteScript
VARIANT CWebDlg::ExecuteScript(CString csCode, CString csLanguage)
{
COleVariant varRet;
IHTMLDocument2* pHTMLDocument2;
IHTMLWindow2* pHTMLWindow2;
LPDISPATCH lpDispatch;
lpDispatch = m_explore.GetDocument();
BSTR bstrCode = _bstr_t((const char *)csCode);
BSTR bstrLang = _bstr_t((const char *)csLanguage);
HRESULT hr;
if(lpDispatch)
{
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDocument2);
if(hr == S_OK)
{
hr = pHTMLDocument2->get_parentWindow(&pHTMLWindow2);
if(hr == S_OK)
{
pHTMLWindow2->execScript(bstrCode, bstrLang, &varRet);
pHTMLWindow2->Release();
}
pHTMLDocument2->Release();
}
lpDispatch->Release();
}
return varRet;
}
示例4: DocumentCompleteExplorerSelectItem
void CIncrementSystemBFDlg::DocumentCompleteExplorerSelectItem(LPDISPATCH pDisp, VARIANT* URL)
{
CString url = URL->bstrVal;
if (url.Find(cUrls.Logon) > 0){
TRACE("UnLoadhook");
unloadhook();
isLogon = true;
}
if (isLogon){
if (url.Find(cUrls.Http1) > 0){
TRACE("Loadhook");
loadhook();
isLogon = false;
}
}
IUnknown* pUnk;
LPDISPATCH lpWBDisp;
HRESULT hr;
pUnk = m_MyIE.GetControlUnknown();
ASSERT(pUnk);
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);
ASSERT(SUCCEEDED(hr));
if (pDisp == lpWBDisp )
{
//TRACE("Web document is finished downloading/n");//这里就是最佳获取时机的判断
}
pUnk->Release();
lpWBDisp->Release();
}
示例5: acedGetIDispatch
void
addCircleThroughCom()
{
AutoCAD::IAcadApplication *pAcad;
AutoCAD::IAcadDocument *pDoc;
AutoCAD::IAcadModelSpace *pMSpace;
HRESULT hr = NOERROR;
LPUNKNOWN pUnk = NULL;
LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE);
if(pAcadDisp==NULL)
return;
hr = pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication,(void**)&pAcad);
pAcadDisp->Release();
if (FAILED(hr))
return;
hr = pAcad->get_ActiveDocument(&pDoc);
pAcad->Release();
if (FAILED(hr))
return;
hr = pDoc->get_ModelSpace(&pMSpace);
pDoc->Release();
if (FAILED(hr))
return;
SAFEARRAYBOUND rgsaBound;
rgsaBound.lLbound = 0L;
rgsaBound.cElements = 3;
long i;
SAFEARRAY* pStartPoint = NULL;
pStartPoint = SafeArrayCreate(VT_R8, 1, &rgsaBound);
i = 0;
double value = 4.0;
SafeArrayPutElement(pStartPoint, &i, &value);
i = 1;
value = 2.0;
SafeArrayPutElement(pStartPoint, &i, &value);
i = 2;
value = 0.0;
SafeArrayPutElement(pStartPoint, &i, &value);
VARIANT pt1;
pt1.vt = VT_ARRAY | VT_R8;
pt1.parray = pStartPoint;
AutoCAD::IAcadCircle *pCircle;
pMSpace->AddCircle(pt1, 2.0, &pCircle);
VariantClear(&pt1);
pMSpace->Release();
}
示例6: OnActivate
void CNetscapeCntrItem::OnActivate()
{
char * pSource = NULL;
const char* ptr;
LPDISPATCH pdisp;
HRESULT hr;
int _convert;
if (m_lpObject->QueryInterface(IID_IDispatch, (void**)&pdisp) == S_OK){
#ifdef XP_WIN32
LPCOLESTR lpOleStr = T2COLE("SaveAs");
hr = pdisp->GetIDsOfNames(IID_NULL, (unsigned short **)&lpOleStr, 1, LOCALE_USER_DEFAULT, &m_idSavedAs);
pdisp->Release();
if (hr == S_OK)
m_bCanSavedByOLE = TRUE;
else
m_idSavedAs = DISPID_UNKNOWN;
#else
m_idSavedAs = DISPID_UNKNOWN;
#endif
}
const char* ptr1 = m_csAddress;
if (NET_IsLocalFileURL((char*)ptr1)) {
XP_ConvertUrlToLocalFile(m_csAddress, &pSource);
m_csDosName = *pSource; // pick up the drive name.
m_csDosName += ":";
m_csDosName += strchr(pSource, '\\'); // pick up the real file name.
ptr = m_csDosName;
FE_ConvertSpace((char*)ptr);
XP_FREE(pSource);
}
// the object does not support ole automation, try to find out if this is a storagefile, so
// we can use OLESave().
if (!m_bCanSavedByOLE) {
#ifdef XP_WIN32 // we will only want to handle saving when the object had storage file.
int _convert;
LPCOLESTR lpsz = A2CW(m_csDosName);
if (StgIsStorageFile(lpsz) == S_OK)
m_bCanSavedByOLE = TRUE;
#else
HRESULT sc1 = StgIsStorageFile(m_csDosName);
if (GetScode(sc1) == S_OK)
m_bCanSavedByOLE = TRUE;
#endif
}
CGenericView* pView = GetActiveView();
CFrameGlue *pFrameGlue = pView->GetFrame();
if(pFrameGlue != NULL) {
m_bLocationBarShowing = pFrameGlue->GetChrome()->GetToolbarVisible(ID_LOCATION_TOOLBAR);
}
COleClientItem::OnActivate();
}
示例7: MyTimerProc
// MyTimerProc is a callback function passed to SetTimer()
VOID CALLBACK MyTimerProc(HWND /*hwnd*/, UINT /*uMsg*/, UINT /*idEvent*/,
DWORD /*dwTime*/)
{
LPDISPATCH pDisp = NULL;
// gpMyCtrl is a global variable of type CMyCtrl*
// _GetEntries() is a static function you get with BEGIN_COM_MAP()
AtlInternalQueryInterface (gpMyCtrl, CMyCtrl::_GetEntries(), IID_IDispatch,
(LPVOID*)&pDisp);
//...
pDisp->Release ();
}
示例8: pDoc
// The open document event handle is the place where the real interface work
// is done.
// Vim gets called from here.
//
HRESULT CCommands::XApplicationEvents::DocumentOpen (IDispatch * theDocument)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState ());
if (! g_bEnableVim)
// Vim not enabled or empty command line entered
return S_OK;
// First get the current file name and line number
// Get the document object
CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
if (! pDoc)
return S_OK;
BSTR FileName;
long LineNr = -1;
// Get the document name
if (FAILED (pDoc->get_FullName (&FileName)))
return S_OK;
LPDISPATCH pDispSel;
// Get a selection object dispatch pointer
if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
{
// Get the selection object
CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);
if (pSel)
// Get the selection line number
pSel->get_CurrentLine (&LineNr);
pDispSel->Release ();
}
// Open the file in Vim and position to the current line
if (VimOpenFile (FileName, LineNr))
{
if (! g_bDevStudioEditor)
{
// Close the document in developer studio
CComVariant vSaveChanges = dsSaveChangesPrompt;
DsSaveStatus Saved;
pDoc->Close (vSaveChanges, &Saved);
}
}
// We're done here
SysFreeString (FileName);
return S_OK;
}
示例9: GetHtmlDocument
IHTMLDocument2Ptr CH_HBarWnd::GetHtmlDocument(){
LPDISPATCH pDispatch = 0;
if(pwb_){
if (FAILED(pwb_->get_Document(&pDispatch))){
return NULL;
}
}
IHTMLDocument2Ptr pHtmlDoc2 = pDispatch;
if(pDispatch)
pDispatch->Release();
return pHtmlDoc2;
}
示例10:
/* Get the flags from the inspector; i.e. whether to sign or encrypt a
message. Returns 0 on success. */
int
get_inspector_composer_flags (LPDISPATCH inspector,
bool *r_sign, bool *r_encrypt)
{
LPDISPATCH button;
int rc = 0;
button = get_button (inspector, "GpgOL_Inspector_Sign");
if (!button)
{
log_error ("%s:%s: Sign button not found", SRCNAME, __func__);
rc = -1;
}
else
{
*r_sign = get_oom_int (button, "State") == msoButtonDown;
button->Release ();
}
button = get_button (inspector, "GpgOL_Inspector_Encrypt");
if (!button)
{
log_error ("%s:%s: Encrypt button not found", SRCNAME, __func__);
rc = -1;
}
else
{
*r_encrypt = get_oom_int (button, "State") == msoButtonDown;
button->Release ();
}
if (!rc)
log_debug ("%s:%s: sign=%d encrypt=%d",
SRCNAME, __func__, *r_sign, *r_encrypt);
return rc;
}
示例11:
const COleDispatchDriver&
COleDispatchDriver::operator=(const COleDispatchDriver& dispatchSrc)
{
if (this != &dispatchSrc)
{
LPDISPATCH lpTemp = m_lpDispatch;
m_lpDispatch = dispatchSrc.m_lpDispatch;
if (m_lpDispatch != NULL)
m_lpDispatch->AddRef();
if (lpTemp != NULL && m_bAutoRelease)
lpTemp->Release();
m_bAutoRelease = TRUE;
}
return *this;
}
示例12:
void CEx24dView::OnDlloleLoad()
{
if(!m_auto.CreateDispatch("Ex24b.Auto")) {
AfxMessageBox("Ex24b.Auto component not found");
return;
}
m_auto.SetTextData(COleVariant("test")); // testing
m_auto.SetLongData(79); // testing
// verify dispatch interface
// {A9515AD7-5B85-11D0-848F-00400526305B}
static const IID IID_IEx24bAuto =
{ 0xa9515ad7, 0x5b85, 0x11d0, { 0x84, 0x8f, 0x0, 0x40, 0x5, 0x26, 0x30, 0x5b } };
LPDISPATCH p;
HRESULT hr = m_auto.m_lpDispatch->QueryInterface(IID_IEx24bAuto,
(void**) &p);
TRACE("OnDlloleLoad -- QueryInterface result = %x\n", hr);
p->Release();
}
示例13: CreateUser
/* CreateUser() - Function for creating a basic User
Parameters
IDirectoryObject *pDirObject - Parent Directory Object for the new User
LPWSTR pwCommonName - Common Name for the new User
IDirectoryObject ** ppDirObjRet - Pointer to the Pointer which will receive the new User
int iUserType - Bitflags for new User:
ADS_User_TYPE_GLOBAL_User,
ADS_User_TYPE_DOMAIN_LOCAL_User,
ADS_User_TYPE_UNIVERSAL_User,
ADS_User_TYPE_SECURITY_ENABLED
*/
HRESULT CreateUser(IDirectoryObject *pDirObject, LPWSTR pwCommonName,LPWSTR pwSamAcctName,IDirectoryObject ** ppDirObjRet)
{
assert(pDirObject);
if (wcslen(pwSamAcctName) >20)
{
MessageBox(NULL,L"SamAccountName CANNOT be bigger than 20 characters",L"Error: CreateSimpleUser()",MB_ICONSTOP);
assert(0);
return E_FAIL;
}
HRESULT hr;
ADSVALUE sAMValue;
ADSVALUE classValue;
LPDISPATCH pDisp;
WCHAR pwCommonNameFull[1024];
ADS_ATTR_INFO attrInfo[] =
{
{ L"objectClass", ADS_ATTR_UPDATE,
ADSTYPE_CASE_IGNORE_STRING, &classValue, 1 },
{L"sAMAccountName", ADS_ATTR_UPDATE,
ADSTYPE_CASE_IGNORE_STRING, &sAMValue, 1},
};
DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO);
classValue.dwType = ADSTYPE_CASE_IGNORE_STRING;
classValue.CaseIgnoreString = L"User";
sAMValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
sAMValue.CaseIgnoreString = pwSamAcctName;
wsprintfW(pwCommonNameFull,L"CN=%s",pwCommonName);
hr = pDirObject->CreateDSObject( pwCommonNameFull, attrInfo,
dwAttrs, &pDisp );
if (SUCCEEDED(hr))
{
hr = pDisp->QueryInterface(IID_IDirectoryObject,(void**) ppDirObjRet);
pDisp->Release();
pDisp = NULL;
}
return hr;
}
示例14:
void
run_explorer_revert_folder (LPDISPATCH button)
{
LPDISPATCH obj;
log_debug ("%s:%s: Enter", SRCNAME, __func__);
/* Notify the user that the general GpgOl function will be disabled
when calling this function. */
if ( opt.disable_gpgol
|| (MessageBox
(NULL/* FIXME: need the hwnd */,
_("You are about to start the process of reversing messages "
"created by GpgOL to prepare deinstalling of GpgOL. "
"Running this command will put GpgOL into a disabled state "
"so that messages are not anymore processed by GpgOL.\n"
"\n"
"You should convert all folders one after the other with "
"this command, close Outlook and then deinstall GpgOL.\n"
"\n"
"Note that if you start Outlook again with GpgOL still "
"being installed, GpgOL will again process messages."),
_("GpgOL"), MB_ICONWARNING|MB_OKCANCEL) == IDOK))
{
if ( MessageBox
(NULL /* Fixme: need hwnd */,
_("Do you want to revert this folder?"),
_("GpgOL"), MB_ICONQUESTION|MB_YESNO) == IDYES )
{
if (!opt.disable_gpgol)
opt.disable_gpgol = 1;
obj = get_oom_object (button,
"get_Parent.get_Parent.get_Parent.get_Parent"
".get_CurrentFolder");
if (obj)
{
gpgol_folder_revert (obj);
obj->Release ();
}
}
}
}
示例15: LoadWebOCFromStream
//
// Function: LoadWebOCFromStream
//
// Description: Takes an IWebBrowser pointer and causes the stream to
// be loaded into the contained HTML Document Object.
//
HRESULT LoadWebOCFromStream(IWebBrowser *pWebBrowser, IStream *pStream)
{
HRESULT hr;
LPDISPATCH pHtmlDoc = NULL;
IPersistStreamInit *pPersistStreamInit = NULL;
// Test for valid pointers.
//
if (!pWebBrowser || !pStream)
return E_POINTER;
// Get to the document object's IDispatch pointer.
//
hr = pWebBrowser->get_Document(&pHtmlDoc);
if (hr)
goto CleanUp;
// Query for IPersistStreamInit
//
hr = pHtmlDoc->QueryInterface(IID_IPersistStreamInit,
(void**)&pPersistStreamInit);
if (hr)
goto CleanUp;
// Tell the document we'll be reinitializing it.
//
hr = pPersistStreamInit->InitNew();
if (hr)
goto CleanUp;
// Load the contents of the stream.
//
hr = pPersistStreamInit->Load(pStream);
CleanUp:
if (pHtmlDoc)
pHtmlDoc->Release();
if (pPersistStreamInit)
pPersistStreamInit->Release();
return hr;
}