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


C++ QueryInterface函数代码示例

本文整理汇总了C++中QueryInterface函数的典型用法代码示例。如果您正苦于以下问题:C++ QueryInterface函数的具体用法?C++ QueryInterface怎么用?C++ QueryInterface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: NS_ENSURE_ARG_POINTER

NS_IMETHODIMP
nsBaseCommandController::GetInterface(const nsIID& aIID, void** aResult)
{
  NS_ENSURE_ARG_POINTER(aResult);

  if (NS_SUCCEEDED(QueryInterface(aIID, aResult))) {
    return NS_OK;
  }

  if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable))) {
    if (mCommandTable) {
      return mCommandTable->QueryInterface(aIID, aResult);
    }
    return NS_ERROR_NOT_INITIALIZED;
  }

  return NS_NOINTERFACE;
}
开发者ID:70599,项目名称:Waterfox,代码行数:18,代码来源:nsBaseCommandController.cpp

示例2: NS_ENSURE_ARG_POINTER

NS_IMETHODIMP sbSeekableChannel::GetInterface(
    const nsIID                 &iid,
    void                        **ppInterface)
{
    void                        *pInterface = nsnull;
    nsresult                    result = NS_OK;

    /* Validate parameters. */
    NS_ENSURE_ARG_POINTER(ppInterface);

    /* Query component for the interface. */
    result = QueryInterface(iid, &pInterface);

    /* Return results. */
    *ppInterface = pInterface;

    return (result);
}
开发者ID:AntoineTurmel,项目名称:nightingale-hacking,代码行数:18,代码来源:SeekableChannel.cpp

示例3: DllGetClassObject

extern "C" HRESULT STDMETHODCALLTYPE DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    // {67fb642f-51cd-4745-8b21-aacd2ec74e62}
    const GUID CLSID_CorProfiler = { 0x67fb642f, 0x51cd, 0x4745, { 0x8b, 0x21, 0xaa, 0xcd, 0x2e, 0xc7, 0x4e, 0x62 } };

    if (ppv == nullptr || rclsid != CLSID_CorProfiler)
    {
        return E_FAIL;
    }

    auto factory = new ClassFactory;
    if (factory == nullptr)
    {
        return E_FAIL;
    }

    return factory->QueryInterface(riid, ppv);
}
开发者ID:ashmind,项目名称:TryRoslyn,代码行数:18,代码来源:dllmain.cpp

示例4: if

HRESULT tomEditCallback::GetClipboardData(THIS_ CHARRANGE FAR * lpchrg, DWORD reco,
                                          LPDATAOBJECT FAR * lplpdataobj) 
{
    // 没有选中任何东西
    if (lpchrg->cpMin == lpchrg->cpMax)
        return E_NOTIMPL ;

    // 获得当前选择内容类型:纯文本、单个图像对象、图文混合
    WORD selection_type = m_edit->GetSelectionType() ;

    if ((selection_type & SEL_TEXT) && !(selection_type & SEL_OBJECT))
    {
        // 纯文本,执行缺省操作即可
        // 但缺省操作会复制富文本的格式、颜色等,所以还得自行处理
        return E_NOTIMPL ;
    }
    else if (selection_type == SEL_OBJECT)
    {
        // 单个图像对象,要提供CF_BITMAP/CF_DIB、CF_HTML、CF_HDROP和内部标准格式
        // 获得图像对象
        REOBJECT reo ;
        reo.cbStruct = sizeof(reo) ;
        reo.cp = lpchrg->cpMin ;
        if (S_OK == m_edit->GetObject(REO_IOB_USE_CP, &reo, REO_GETOBJ_POLEOBJ))
        {
            *lplpdataobj = NULL ;
            reo.poleobj->QueryInterface(IID_IDataObject, (void**)lplpdataobj) ;
            reo.poleobj->Release() ;
            if (*lplpdataobj != NULL)
                return S_OK ;
        }
    }
    else if ((selection_type & (SEL_OBJECT)) && (selection_type & SEL_TEXT))
    {
        // 图文混合
        if (PrepareClipboardData() && S_OK == QueryInterface(IID_IDataObject, (void**)lplpdataobj))
        {
            if (*lplpdataobj != NULL)
                return S_OK ;
        }
    }

    return E_NOTIMPL ;
}
开发者ID:baogechen,项目名称:foundit,代码行数:44,代码来源:tomEditCallback.cpp

示例5: GetSite

VALUE CRScriptCore::GetOleObject(VALUE self, LPCOLESTR pstrName)
{
	ItemMapIter it = m_mapItem.find(pstrName);
	if (it == m_mapItem.end())
	{
		it = (m_mapItem.insert(ItemMap::value_type(pstrName, new CItemHolder))).first;
	}

	VALUE obj = Qnil;
	IDispatch* pDisp = NULL;
	IActiveScriptSite* pSite = GetSite();
	if (pSite)
	{
		pDisp = (*it).second->GetDispatch(pSite, const_cast<LPOLESTR>(pstrName), (m_dwThreadID == GetCurrentThreadId()));
		pSite->Release();
	}
	if (pDisp)
	{
		oledataex *pole;
		// setting free function is not required. because ScriptEngine hold it.
		obj = Data_Make_Struct(self, oledataex, 0, 0, pole);
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
		IDispatchEx* pEx;
		if (QueryInterface(IID_IRubyEngine, (void**)&pole->pEngine) == S_OK)
		{
			// adjust ref count (because never release the ptr in WIN32OLEEX)
			pole->pEngine->Release();
		}
		if (pDisp->QueryInterface(IID_IDispatchEx, (void**)&pEx) == S_OK)
		{
			pole->pDispatch = pEx;
			pole->pServiceProvider = this;
			pDisp->Release();
		}
		else
#endif
		{
			pole->pDispatch = pDisp;
		}
		ATLTRACE(_T("add OLE Object into list:%08X\n"), pole);
		m_listOleObj.push_back(reinterpret_cast<oledata*>(pole));
	}
	return obj;
}
开发者ID:arton,项目名称:RScript20,代码行数:44,代码来源:RScriptCore.cpp

示例6: AddEntity

entity_id_t CComponentManager::AddEntity(const std::wstring& templateName, entity_id_t ent)
{
	ICmpTemplateManager *cmpTemplateManager = static_cast<ICmpTemplateManager*> (QueryInterface(SYSTEM_ENTITY, IID_TemplateManager));
	if (!cmpTemplateManager)
	{
		debug_warn(L"No ICmpTemplateManager loaded");
		return INVALID_ENTITY;
	}

	// TODO: should assert that ent doesn't exist

	const CParamNode* tmpl = cmpTemplateManager->LoadTemplate(ent, utf8_from_wstring(templateName), -1);
	if (!tmpl)
		return INVALID_ENTITY; // LoadTemplate will have reported the error

	// Construct a component for each child of the root element
	const CParamNode::ChildrenMap& tmplChilds = tmpl->GetChildren();
	for (CParamNode::ChildrenMap::const_iterator it = tmplChilds.begin(); it != tmplChilds.end(); ++it)
	{
		// Ignore attributes on the root element
		if (it->first.length() && it->first[0] == '@')
			continue;

		CComponentManager::ComponentTypeId cid = LookupCID(it->first);
		if (cid == CID__Invalid)
		{
			LOGERROR(L"Unrecognised component type name '%hs' in entity template '%ls'", it->first.c_str(), templateName.c_str());
			return INVALID_ENTITY;
		}

		if (!AddComponent(ent, cid, it->second))
		{
			LOGERROR(L"Failed to construct component type name '%hs' in entity template '%ls'", it->first.c_str(), templateName.c_str());
			return INVALID_ENTITY;
		}

		// TODO: maybe we should delete already-constructed components if one of them fails?
	}

	CMessageCreate msg(ent);
	PostMessage(ent, msg);

	return ent;
}
开发者ID:nahumfarchi,项目名称:0ad,代码行数:44,代码来源:ComponentManager.cpp

示例7: V

int DX11Engine::getOutput(IUnknown* pDevice, IUnknown** pOutputs, int sz) const {
    auto ptr = reinterpret_cast<ID3D11Device*>(pDevice);
    HRESULT hr = S_OK;
    std::unique_ptr<IDXGIDevice, COMDeleter>    pDXGIDevice;
    std::unique_ptr<IDXGIAdapter, COMDeleter>   pDXGIAdapter;

    V(ptr->QueryInterface(__uuidof(IDXGIDevice), ref(pDXGIDevice)));
    V(pDXGIDevice->GetParent(__uuidof(IDXGIAdapter), ref(pDXGIAdapter)));

    UINT i = 0;
    std::unique_ptr<IDXGIOutput, COMDeleter> pOutput;
    while (pDXGIAdapter->EnumOutputs(i, ref(pOutput)) != DXGI_ERROR_NOT_FOUND && 
        i < uint32_t(sz))
    {
        pOutputs[i] = pOutput.release();
        ++i;
    }
    return i;
}
开发者ID:Zhou-Zhenglong,项目名称:star,代码行数:19,代码来源:SDX11Engine.cpp

示例8: QueryInterface

NS_INTERFACE_MAP_END


///////////////////////////////////////////////////////////////////////////////
// nsIInterfaceRequestor

NS_IMETHODIMP CWebBrowserContainer::GetInterface(const nsIID & aIID, void * *result)
{
    *result = 0;
    if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
    {
        if (mOwner && mOwner->mWebBrowser)
        {
            return mOwner->mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) result);
        }
        return NS_ERROR_NOT_INITIALIZED;
    }
    return QueryInterface(aIID, result);
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:19,代码来源:WebBrowserContainer.cpp

示例9: QueryInterface

NS_INTERFACE_MAP_END

////////////////////////////////////////////////////////////////////////////////


/* void getInterface (in nsIIDRef uuid, [iid_is (uuid), retval] out nsQIResult result); */
NS_IMETHODIMP 
BrowserWindow::GetInterface(const nsIID & aIID, void * *aInstancePtr)
{
	if ( aIID.Equals( NS_GET_IID( nsIDOMWindow ) ) ) {
		if ( webBrowser ) {
			return webBrowser->GetContentDOMWindow( ( nsIDOMWindow** )aInstancePtr );
		};

		return NS_ERROR_NOT_INITIALIZED;
	};

	return QueryInterface( aIID, aInstancePtr );
}
开发者ID:noqisofon,项目名称:gluezilla,代码行数:19,代码来源:BrowserWindow.cpp

示例10: QueryInterface

HRESULT CDwnDoc::QueryService(BOOL fBindOnApt, REFGUID rguid, REFIID riid, void** ppvObj)
{
    HRESULT hr;

    if((rguid==IID_IAuthenticate || rguid==IID_IWindowForBindingUI) && (rguid==riid))
    {
        hr = QueryInterface(rguid, ppvObj);
    }
    else if(fBindOnApt && IsDocThread() && _pDoc)
    {
        hr = _pDoc->QueryService(rguid, riid, ppvObj);
    }
    else
    {
        *ppvObj = NULL;
        hr = E_NOINTERFACE;
    }

    return hr;
}
开发者ID:hufuman,项目名称:xindows,代码行数:20,代码来源:DwnDoc.cpp

示例11: QueryInterface

    HRESULT PendingBreakpoint::SendBoundEvent( IEnumDebugBoundBreakpoints2* enumBPs )
    {
        HRESULT hr = S_OK;
        CComPtr<IDebugPendingBreakpoint2>       pendBP;
        CComPtr<IDebugEngine2>                  engine;
        RefPtr<BreakpointBoundEvent>            event;

        hr = QueryInterface( __uuidof( IDebugPendingBreakpoint2 ), (void**) &pendBP );
        _ASSERT( hr == S_OK );

        hr = mEngine->QueryInterface( __uuidof( IDebugEngine2 ), (void**) &engine );
        _ASSERT( hr == S_OK );

        hr = MakeCComObject( event );
        if ( FAILED( hr ) )
            return hr;

        event->Init( enumBPs, pendBP );

        return event->Send( mCallback, engine, NULL, NULL );
    }
开发者ID:Kentorix,项目名称:MagoWrapper,代码行数:21,代码来源:PendingBreakpoint.cpp

示例12: NS_ENSURE_ARG_POINTER

NS_INTERFACE_MAP_END

//*****************************************************************************
// WebBrowserChrome::nsIInterfaceRequestor
//*****************************************************************************   

NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
    NS_ENSURE_ARG_POINTER(aInstancePtr);

    *aInstancePtr = 0;
    if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
    {
        if (mWebBrowser)
        {
            return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
        }
        return NS_ERROR_NOT_INITIALIZED;
    }
    return QueryInterface(aIID, aInstancePtr);
}
开发者ID:adamroach,项目名称:gecko-dev,代码行数:21,代码来源:WebBrowserChrome.cpp

示例13: NS_ADDREF_THIS

NS_IMETHODIMP
FetchDriver::GetInterface(const nsIID& aIID, void **aResult)
{
  if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
    *aResult = static_cast<nsIChannelEventSink*>(this);
    NS_ADDREF_THIS();
    return NS_OK;
  }
  if (aIID.Equals(NS_GET_IID(nsIStreamListener))) {
    *aResult = static_cast<nsIStreamListener*>(this);
    NS_ADDREF_THIS();
    return NS_OK;
  }
  if (aIID.Equals(NS_GET_IID(nsIRequestObserver))) {
    *aResult = static_cast<nsIRequestObserver*>(this);
    NS_ADDREF_THIS();
    return NS_OK;
  }

  return QueryInterface(aIID, aResult);
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:21,代码来源:FetchDriver.cpp

示例14: lock

HRESULT FFmpegDecodeFilter::GetService(REFIID riid, void** ppv)
{
	std::lock_guard<decltype(_mutex)> lock(_mutex);

	if (_services == NULL) {
		avcodec_register_all();
		av_lockmgr_register(&AVCodecMTLockCallback); //or to use InitOnceExecuteOnce.

		auto p = new(std::nothrow) FFmpegDecodeServices();
		if (p == NULL)
			return E_OUTOFMEMORY;
		p->QueryInterface(IID_PPV_ARGS(&_services));
		p->Release();
	}

	if (ppv == NULL)
		return E_POINTER;
	if (_services == NULL)
		return E_ABORT;
	return _services->QueryInterface(riid, ppv);
}
开发者ID:saki-saki,项目名称:SYEngine,代码行数:21,代码来源:FFmpegDecodeFilter.cpp

示例15: CHECK_E_POINTER

STDMETHODIMP CVideoViewControl::OnInitialized(IServiceProvider *pServiceProvider)
{
	CHECK_E_POINTER(pServiceProvider);
	m_pServiceProvider = pServiceProvider;

	CComPtr<IUnknown> pUnk;
	RETURN_IF_FAILED(QueryInterface(__uuidof(IUnknown), (LPVOID*)&pUnk));

	STARTUPINFO si = { 0 };
	PROCESS_INFORMATION pi = { 0 };
	auto wstrParams = std::to_wstring((long long)m_hWnd);
	CString strCmdLine(L"minitwivp.exe");
	strCmdLine += CString(L" ") + wstrParams.c_str();
	TCHAR lpszCmdLine[100];
	wcscpy(lpszCmdLine, strCmdLine);
	auto res = CreateProcess(
		NULL,
		lpszCmdLine,
		NULL,
		NULL,
		FALSE,
		NULL,
		NULL,
		NULL,
		&si,
		&pi
		);
	
	if (!res)
	{
		HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
		HandleError(hr);
	}

    CloseHandle(pi.hThread);
	m_hProcess = pi.hProcess;
	SetTimer(1, 10 * 1000); //waiting for child process init

	return S_OK;
}
开发者ID:ip821,项目名称:minitwi,代码行数:40,代码来源:VideoViewControl.cpp


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