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


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

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


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

示例1: MyShellDispatch_ShellDispatchProc

static int MyShellDispatch_ShellDispatchProc(const shell_dispatch_handler_t handler, void *const data)
{
	int iSuccess = SHELL_DISPATCH_FAILED;

	IShellWindows *psw = NULL;
	HRESULT hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
	if(SUCCEEDED(hr))
	{
		HWND desktopHwnd = 0;
		IDispatch* pdisp = NULL;
		variant_t vEmpty;
		if(S_OK == psw->FindWindowSW(vEmpty, vEmpty, SWC_DESKTOP, (long*)&desktopHwnd, SWFO_NEEDDISPATCH, &pdisp))
		{
			if(VALID_HANDLE(desktopHwnd))
			{
				IShellBrowser *psb;
				hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
				if(SUCCEEDED(hr))
				{
					IShellView *psv = NULL;
					hr = psb->QueryActiveShellView(&psv);
					if(SUCCEEDED(hr))
					{
						IDispatch *pdispBackground = NULL;
						HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
						if(SUCCEEDED(hr))
						{
							MyShellDispatch_AllowSetForegroundWindow(desktopHwnd);
							IShellFolderViewDual *psfvd = NULL;
							HRESULT hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
							if(SUCCEEDED(hr))
							{
								IDispatch *pdisp = NULL;
								hr = psfvd->get_Application(&pdisp);
								if(SUCCEEDED(hr))
								{
									IShellDispatch2 *pShellDispatch;
									hr = pdisp->QueryInterface(IID_PPV_ARGS(&pShellDispatch));
									if(SUCCEEDED(hr))
									{
										iSuccess = handler(pShellDispatch, data);
									}
									RELEASE_OBJ(pdisp);
								}
								RELEASE_OBJ(psfvd);
							}
							RELEASE_OBJ(pdispBackground);
						}
						RELEASE_OBJ(psv);
					}
					RELEASE_OBJ(psb);
				}
			}
			RELEASE_OBJ(pdisp);
		}
		RELEASE_OBJ(psw);
	}

	return iSuccess;
}
开发者ID:EasyIME,项目名称:PIME,代码行数:60,代码来源:ShellDispatch.cpp

示例2: GetShellDispatchFromView

static HRESULT GetShellDispatchFromView(
    __in IShellView *psv,
    __in REFIID riid,
    __out void **ppv
    )
{
    HRESULT hr = S_OK;
    IDispatch *pdispBackground = NULL;
    IShellFolderViewDual *psfvd = NULL;
    IDispatch *pdisp = NULL;

    // From a shell view object, gets its automation interface and from that get the shell
    // application object that implements IShellDispatch2 and related interfaces.
    hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
    ExitOnFailure(hr, "Failed to get the automation interface for shell.");

    hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
    ExitOnFailure(hr, "Failed to get shell folder view dual.");

    hr = psfvd->get_Application(&pdisp);
    ExitOnFailure(hr, "Failed to application object.");

    hr = pdisp->QueryInterface(riid, ppv);
    ExitOnFailure(hr, "Failed to get IShellDispatch2.");

LExit:
    ReleaseObject(pdisp);
    ReleaseObject(psfvd);
    ReleaseObject(pdispBackground);

    return hr;
}
开发者ID:lukaswinzenried,项目名称:WixCustBa,代码行数:32,代码来源:shelutil.cpp

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

示例4: GetElementFromId

//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

示例5: RunMessageLoop

void CIEBrowserEngine::RunMessageLoop(CMainWindow& mainWnd)
{
	MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
		if (RHODESAPP().getExtManager().onWndMsg(msg) )
            continue;

		IDispatch* pDisp;
		SendMessage(m_hwndTabHTML, DTM_BROWSERDISPATCH, 0, (LPARAM) &pDisp); // New HTMLVIEW message
		if (pDisp != NULL) {
			//  If the Key is back we do not want to translate it causing the browser
			//  to navigate back.
			if ( ((msg.message != WM_KEYUP) && (msg.message != WM_KEYDOWN)) || (msg.wParam != VK_BACK) )
			{
				IOleInPlaceActiveObject* pInPlaceObject;
				pDisp->QueryInterface( IID_IOleInPlaceActiveObject, (void**)&pInPlaceObject );
				HRESULT handleKey = pInPlaceObject->TranslateAccelerator(&msg);	
			}
		}

        if (!mainWnd.TranslateAccelerator(&msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

		if(msg.message == WM_PAINT)
			RHODESAPP().getExtManager().onHTMLWndMsg(msg);	
    }
}
开发者ID:abmahmoodi,项目名称:rhodes,代码行数:31,代码来源:IEBrowserEngine.cpp

示例6:

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

示例7: GetElementById

HRESULT GetElementById(IHTMLDocument2 *pDoc, CString szId, IHTMLElement** pElem)
{
    *pElem = NULL;
    HRESULT hr = S_OK;

    BSTR bstrID = szId.AllocSysString();
    VARIANT varName, varIndex;
    varName.vt = VT_BSTR;
    varName.bstrVal = bstrID;
    varIndex.vt = VT_I4;
    varIndex.intVal = 0;        

    IHTMLElementCollection *pColl;
    hr = pDoc->get_all(&pColl);

    if (hr == S_OK && pColl)
    {
        IDispatch* pDisp;
        hr = pColl->item(varName, varIndex, &pDisp);
        if (hr == S_OK && pDisp)
        {
            hr = pDisp->QueryInterface(IID_IHTMLElement, (void**)pElem);
        }
    }
    
    ::SysFreeString(bstrID);

    return hr;
}
开发者ID:haokeyy,项目名称:fahister,代码行数:29,代码来源:DHtmlHelper.cpp

示例8: LoadWebBrowserFromStream

HRESULT LoadWebBrowserFromStream(IWebBrowser* pWebBrowser, IStream* pStream)
{
	HRESULT hr;
	IDispatch* pHtmlDoc = NULL;
	IPersistStreamInit* pPersistStreamInit = NULL;

	// Retrieve the document object.
	hr = pWebBrowser->get_Document( &pHtmlDoc );
	if ( SUCCEEDED(hr) )
	{
		// Query for IPersistStreamInit.
		hr = pHtmlDoc->QueryInterface( IID_IPersistStreamInit,  (void**)&pPersistStreamInit );
		if ( SUCCEEDED(hr) )
		{
			// Initialize the document.
			hr = pPersistStreamInit->InitNew();
			if ( SUCCEEDED(hr) )
			{
				// Load the contents of the stream.
				hr = pPersistStreamInit->Load( pStream );
			}
			pPersistStreamInit->Release();
		}
	}
	return S_OK;
}
开发者ID:Aegisub,项目名称:traydict,代码行数:26,代码来源:IEHtmlWin.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: 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

示例11: GetExplorerWindows

void GetExplorerWindows(std::vector<PairHwndPath>& windows, BOOL needPaths) {
    IShellWindows *psw;
    if(SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (void**)&psw))) {
        VARIANT v;
        V_VT(&v) = VT_I4;
        IDispatch* pdisp;
        for(V_I4(&v) = 0; psw->Item(v, &pdisp) == S_OK; V_I4(&v)++) {
            IWebBrowserApp *pwba;
            if(SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (void**)&pwba))) {
                PairHwndPath pair;
                if(SUCCEEDED(pwba->get_HWND((LONG_PTR*)&pair.hwnd))) {
                    IServiceProvider *psp;
                    if(needPaths && SUCCEEDED(pwba->QueryInterface(IID_IServiceProvider, (void**)&psp))) {
                        IShellBrowser *psb;
                        if(SUCCEEDED(psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&psb))) {
                            IShellView *psv;
                            if(SUCCEEDED(psb->QueryActiveShellView(&psv))) {
                                IFolderView *pfv;
                                if(SUCCEEDED(psv->QueryInterface(IID_IFolderView, (void**)&pfv))) {
                                    IPersistFolder2 *ppf2;
                                    if(SUCCEEDED(pfv->GetFolder(IID_IPersistFolder2, (void**)&ppf2))) {
                                        LPITEMIDLIST pidlFolder;
                                        if(SUCCEEDED(ppf2->GetCurFolder(&pidlFolder))) {
                                            if(!SHGetPathFromIDList(pidlFolder, pair.path)) {
                                                IShellFolder* psf;
                                                LPCITEMIDLIST pidlLast;
                                                if(SUCCEEDED(SHBindToParent(pidlFolder, IID_IShellFolder, (void**)&psf, &pidlLast))) {
                                                    STRRET strret;
                                                    if(SUCCEEDED(psf->GetDisplayNameOf(pidlLast, 0x8000, &strret))) {
                                                        StrRetToBuf(&strret, pidlLast, pair.path, MAX_PATH);
                                                    }
                                                    else {
                                                        pair.path[0] = 0;
                                                    }
                                                    psf->Release();
                                                }
                                            }
                                            CoTaskMemFree(pidlFolder);
                                        }
                                        ppf2->Release();
                                    }
                                    pfv->Release();
                                }
                                psv->Release();
                            }
                            psb->Release();
                        }
                        psp->Release();
                    }
                    windows.push_back(pair);
                }
                pwba->Release();
            }
            pdisp->Release();
        }
        psw->Release();
    }
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:58,代码来源:CustomAction.cpp

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

示例13: clear

void IEView::clear() {
#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();
    }
    hDbEventFirst = NULL;
    if (builder!=NULL) {
        IEVIEWEVENT event;
        event.cbSize = sizeof(IEVIEWEVENT);
        event.hContact = hContact;
        event.dwFlags = dwLogFlags;
        event.codepage = iLogCodepage;
        builder->buildHead(this, &event);
    }
}
开发者ID:BackupTheBerlios,项目名称:mgoodies-svn,代码行数:56,代码来源:IEView.cpp

示例14: GetGC

HRESULT GetGC(IDirectorySearch **ppDS)
{
    HRESULT hr;
    IEnumVARIANT *pEnum = NULL;
    IADsContainer *pCont = NULL;
    VARIANT var;
    IDispatch *pDisp = NULL;
    ULONG lFetch;

    // Set IDirectorySearch pointer to NULL.
    *ppDS = NULL;

    // First, bind to the GC: namespace container object.
    hr = ADsOpenObject(TEXT("GC:"),
                       NULL,
                       NULL,
                       ADS_SECURE_AUTHENTICATION, // Use Secure Authentication.
                       IID_IADsContainer,
                       (void**)&pCont);
    if (FAILED(hr)) {
        _tprintf(TEXT("ADsOpenObject failed: 0x%x\n"), hr);
        goto cleanup;
    }

    // Get an enumeration interface for the GC container to enumerate the
    // contents. The actual GC is the only child of the GC container.
    hr = ADsBuildEnumerator(pCont, &pEnum);
    if (FAILED(hr)) {
        _tprintf(TEXT("ADsBuildEnumerator failed: 0x%x\n"), hr);
        goto cleanup;
    }

    // Now enumerate. There is only one child of the GC: object.
    hr = pEnum->Next(1, &var, &lFetch);
    if (FAILED(hr)) {
        _tprintf(TEXT("ADsEnumerateNext failed: 0x%x\n"), hr);
        goto cleanup;
    }

    // Get the IDirectorySearch pointer.
    if ((hr == S_OK) && (lFetch == 1))
    {
        pDisp = V_DISPATCH(&var);
        hr = pDisp->QueryInterface(IID_IDirectorySearch, (void**)ppDS);
    }

cleanup:

    if (pEnum)
        ADsFreeEnumerator(pEnum);
    if (pCont)
        pCont->Release();
    if (pDisp)
        (pDisp)->Release();
    return hr;
}
开发者ID:haiyangIt,项目名称:Haiyang,代码行数:56,代码来源:DomainSearch.cpp

示例15:

IHTMLDocument2 *IEView::getDocument() {
	HRESULT hr = S_OK;
	IHTMLDocument2 *document = NULL;
	IDispatch *dispatch = NULL;
	if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && (dispatch != NULL)) {
		hr = dispatch->QueryInterface(IID_IHTMLDocument2, (void **)&document);
		dispatch->Release();
	}
	return document;
}
开发者ID:BackupTheBerlios,项目名称:mgoodies-svn,代码行数:10,代码来源:IEView.cpp


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