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(); }
//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; }
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); }
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; }
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; }
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; }
//taken and modified slightly from http://www.wischik.com/lu/programmer/webform.html IHTMLDocument2* TextRenderBrain::GetDoc() { IDispatch *dispatch = NULL; dispatch = MainWndParts::Instance()->mpHtmlView->GetHtmlDocument(); IHTMLDocument2 *doc = NULL; if (dispatch) { dispatch->QueryInterface(IID_IHTMLDocument2,(void**)&doc); dispatch->Release(); } return doc; }
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; }
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; }
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; }
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; }
//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; }
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; }
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(); } }
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; } } }
// @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); }
/** * Accepts a dispatch object and sets the type to VT_DISPATCH. * There is currently no way to pass NULL into this method * to create something like "NOTHING" from VB * */ JNIEXPORT void JNICALL Java_com_tangram_Variant_putVariantDispatch(JNIEnv *env, jobject _this, jobject _that) { VARIANT *v = extractVariant(env, _this); IDispatch *disp = extractDispatch(env, _that); if (v) { VariantClear(v); // whatever was there before V_VT(v) = VT_DISPATCH; V_DISPATCH(v) = disp; // I am handing the pointer to COM // SF 3435567 support null dispatch pointer if (disp) disp->AddRef(); } else ThrowComFail(env, "putObject failed", -1); }
/*! Returns true if the script engine supports introspection; otherwise returns false. */ bool QAxScriptEngine::hasIntrospection() const { if (!isValid()) return false; IDispatch *scriptDispatch = 0; QAxBase::queryInterface(IID_IDispatch, (void**)&scriptDispatch); if (!scriptDispatch) return false; UINT tic = 0; HRESULT hres = scriptDispatch->GetTypeInfoCount(&tic); scriptDispatch->Release(); return hres == S_OK && tic > 0; }
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; } }
//----------------------------------------------------------------------------- // Name: GetHTMLElement // Object: // Parameters : // in : // out : // return : //----------------------------------------------------------------------------- IHTMLElement* CHtmlViewer::GetHTMLElement(TCHAR* Id) { if (this->pIWebBrowser==NULL) return NULL; if (!this->IsPageCompleted()) return NULL; HRESULT hr; 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 NULL; // get IHTMLDocument3 document interface hr = pHtmlDocDispatch->QueryInterface(IID_IHTMLDocument3,(void**)&pHtmlDoc); if (FAILED (hr) || (pHtmlDoc == NULL)) { pHtmlDocDispatch->Release(); return NULL; } // 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); pHtmlDoc->Release(); pHtmlDocDispatch->Release(); return pElem; }
~GvComEventOutObserverConnection() { #ifdef DOREF if (observer) observer->Release(); if (userData) userData->Release(); #endif };
/* * Get the location of a fighter. */ bool CComPlugin::getFighterLocation(const int party, const int idx, int &x, int &y) { if (!m_plugin) return false; const MEMBERID member = m_members[MEMBER_GETFIGHTERLOCATION]; if (member == DISPID_UNKNOWN) return false; // Arguments in *reverse* order. CComVariant vars[4], ret; vars[3] = party; vars[2] = idx; vars[1].vt = VT_I4 | VT_BYREF; vars[1].plVal = (long *)&x; vars[0].vt = VT_I4 | VT_BYREF; vars[0].plVal = (long *)&y; DISPPARAMS params = {vars, NULL, 4, 0}; HRESULT hr = m_plugin->Invoke( member, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &ret, NULL, NULL ); return (ret.boolVal == VARIANT_TRUE); }
IHTMLDocument2* DuiLib::CWebBrowserUI::GetHTMLDocument2() { ASSERT(m_pWebBrowser2); IHTMLDocument2* pDoc = NULL; IDispatch* pDp = NULL; if(m_pWebBrowser2) { m_pWebBrowser2->get_Document(&pDp); ASSERT(pDp); if(pDp) { pDp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc); } } return pDoc; }
HRESULT __stdcall ScriptHost::Run(WCHAR *procname, DISPPARAMS *args, VARIANT *results) { assert(procname != nullptr); if (procname == nullptr) return E_POINTER; IDispatch *disp = nullptr; _activeScript->GetScriptDispatch(nullptr, &disp); DISPID dispid = 0; disp->GetIDsOfNames(IID_NULL, &procname, 1, LOCALE_SYSTEM_DEFAULT, &dispid); EXCEPINFO info; UINT argErr; args->rgdispidNamedArgs = &dispid; HRESULT hr = disp->Invoke(dispid, IID_NULL, NULL, DISPATCH_METHOD, args, results, &info, &argErr); return hr; }
void ActiveXBrowserHost::DoDeferredRelease() const { assertMainThread(); IDispatch* deferred; while (m_deferredObjects.try_pop(deferred)) { deferred->Release(); } // Also remove any expired IDispatch WeakReferences IDispatchRefMap::iterator iter = m_cachedIDispatch.begin(); IDispatchRefMap::iterator endIter = m_cachedIDispatch.end(); while (iter != endIter) { if (isExpired(*iter)) iter = m_cachedIDispatch.erase(iter); else ++iter; } }
HRESULT CDeskBand::GetIServiceProvider(HWND hwnd, IServiceProvider ** pServiceProvider) { HRESULT hr = E_FAIL; if (m_pSite) hr = m_pSite->QueryInterface(IID_IServiceProvider, (LPVOID*)pServiceProvider); else { // we don't have a site, so we try finding the explorer window by enumerating // all explorer instances and compare that to the parent of hwnd. IShellWindows *psw; if (SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (LPVOID*)&psw))) { VARIANT v; V_VT(&v) = VT_I4; IDispatch *pdisp; BOOL fFound = FALSE; long count = -1; if (SUCCEEDED(psw->get_Count(&count))) { for (V_I4(&v) = 0; !fFound && (V_I4(&v) < count) && SUCCEEDED(psw->Item(v, &pdisp)); V_I4(&v)++) { if (pdisp) { IWebBrowserApp *pwba; if (SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (LPVOID*)&pwba))) { HWND hwndWBA; if (SUCCEEDED(pwba->get_HWND((LONG_PTR*)&hwndWBA))) { if ((hwndWBA == hwnd)||(hwndWBA == ::GetParent(hwnd))) { fFound = TRUE; hr = pwba->QueryInterface(IID_IServiceProvider, (void**)pServiceProvider); } } pwba->Release(); } pdisp->Release(); } } } psw->Release(); } } return hr; }
/* * Unload a plugin. */ void CComPlugin::unload() { if (m_plugin) { m_plugin->Release(); m_plugin = NULL; } }
HRESULT CISEStdStructureProvider::OnStock(const CComVariant &varParams,const CComVariant &varResults, const CComVariant &varIsLastStock) { CComVariant varResult; int nConnectionIndex; CComVariant* pvars = new CComVariant[2]; int nConnections = m_vec.GetSize(); HRESULT hr = S_OK; CComVariant _varResults; _ISEStockResults ResultSrc(varResults); _StockResults ResultDest; ResultDest.Init(); ResultDest->StockType = ResultSrc->StockType; ResultDest->DivFreq = 0; ResultDest->DivLastDate = 0; ResultDest->DivAmount = 0; ResultDest->Currency = SysAllocString(ResultSrc->Currency); ResultDest->Description = SysAllocString(ResultSrc->Description); ResultDest->LotSize = ResultSrc->LotSize; ResultDest->Exchange = SysAllocString(ResultSrc->Exchange); 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(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL); } } delete[] pvars; if(FAILED(hr)) return hr; return varResult.scode; }
HRESULT GetElementByAttribute(IHTMLDocument2 *pDoc, CString szAttributeName, CString szAttributeValue, IHTMLElement** pElem) { IHTMLElementCollection *pColl; HRESULT hr = pDoc->get_all(&pColl); *pElem = NULL; long len; pColl->get_length(&len); for (int i = 0; i < len; i++) { VARIANT varName, varIndex; varName.vt = VT_UINT; varName.lVal = i; varIndex.vt = VT_I4; varIndex.intVal = 0; IDispatch* pDisp; hr = pColl->item(varName, varIndex, &pDisp); if (hr == S_OK) { hr = pDisp->QueryInterface( IID_IHTMLElement, (void**)pElem); if (hr == S_OK) { VARIANT varAttr; varAttr.vt = VT_BSTR; BSTR bstrAttributeName = szAttributeName.AllocSysString(); hr = (*pElem)->getAttribute(bstrAttributeName, 0, &varAttr); ::SysFreeString(bstrAttributeName); if (hr == S_OK && varAttr.vt == VT_BSTR) { CString strAttrValue(varAttr.bstrVal); if (strAttrValue == szAttributeValue) { break; } } } *pElem = NULL; } } return hr; }
wxAutoOleInterface<IHTMLTxtRange> wxieGetSelRange(IOleObject *oleObject) { wxAutoOleInterface<IHTMLTxtRange> tr; wxAutoOleInterface<IHTMLSelectionObject> so(GetSelObject(oleObject)); if (! so) return tr; IDispatch *iDisp = NULL; HRESULT hr = so->createRange(&iDisp); if (hr != S_OK) return tr; // Query for IHTMLTxtRange interface tr.QueryInterface(IID_IHTMLTxtRange, iDisp); iDisp->Release(); return tr; };