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


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

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


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

示例1: UtGetClassID

FARINTERNAL_(BOOL) UtGetClassID(LPUNKNOWN lpUnk, CLSID FAR* lpClsid)
{
	VDATEHEAP();

	LPOLEOBJECT lpOleObj; // IOleObject pointer
	LPPERSIST lpPersist; // IPersist pointer

	// try to ask it as an object
	if (lpUnk->QueryInterface(IID_IOleObject,
			(LPLPVOID)&lpOleObj) == NOERROR)
	{
		lpOleObj->GetUserClassID(lpClsid);
		lpOleObj->Release();
		return(TRUE);
	}       
	
	// try to ask it as a persistent object
	if (lpUnk->QueryInterface(IID_IPersist,
			(LPLPVOID)&lpPersist) == NOERROR)
	{
		lpPersist->GetClassID(lpClsid);
		lpPersist->Release();
		return(TRUE);
	}
	
	*lpClsid = CLSID_NULL;
	return(FALSE);
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:28,代码来源:ole2util.cpp

示例2: MAKEWPARAM

STDMETHODIMP CIEControlSite::XDocHostUIHandler::ShowContextMenu(
    DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdTarget, LPDISPATCH pdispReserved)
{
    METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler);
    return S_FALSE;

    // 点击右键添加到收藏夹
    HWND hwnd;
    CComPtr<IOleCommandTarget> spCT;
    CComPtr<IOleWindow> spWnd;

    HRESULT hr = pcmdTarget->QueryInterface(IID_IOleCommandTarget, (void**)&spCT);
    if ( FAILED(hr) )
        return S_FALSE;

    hr = pcmdTarget->QueryInterface(IID_IOleWindow, (void**)&spWnd);
    if ( FAILED(hr) )
        return S_FALSE;

    hr = spWnd->GetWindow(&hwnd);

#define ID_IE_ID_ADDFAV 2261
    ::SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(LOWORD(ID_IE_ID_ADDFAV), 0x0), 0 );

    return S_OK;
}
开发者ID:jiaofeng,项目名称:Fire-IE,代码行数:26,代码来源:IEControlSite.cpp

示例3: OnInitDialog

BOOL CHTMLContainerDlg::OnInitDialog()
{
	AfxEnableControlContainer();

	CDialog::OnInitDialog();

	RECT rectClient;
	GetClientRect(&rectClient);

	// if we've been created from the dynamic template
	// set the caption
	if(!m_lpszTemplateName)
		SetWindowText(m_strDlgCaption);

	// check if there is a browser control on the dialog
	// already
	CWnd *pCtrl = GetDlgItem(AFX_IDC_BROWSER);
	LPUNKNOWN lpUnk;
	if(pCtrl)
	{
		lpUnk = pCtrl->GetControlUnknown();
		if (lpUnk && SUCCEEDED(lpUnk->QueryInterface(IID_IWebBrowser2, (void **) &m_pBrowserApp)))
		{
			m_wndBrowser.Attach(pCtrl->m_hWnd);
			m_bAttachedControl = TRUE;
		}
	}
	if(m_pBrowserApp == NULL)
	{
		// create the control window
		m_wndBrowser.CreateControl(CLSID_WebBrowser, NULL,
			WS_VISIBLE | WS_CHILD, rectClient, this, AFX_IDC_BROWSER);
		lpUnk = m_wndBrowser.GetControlUnknown();
		if(FAILED(lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp)))
		{
			m_wndBrowser.DestroyWindow();
			DestroyWindow();
			return TRUE;
		}
	}
	Navigate(m_strURL);

	m_pBrowserApp->put_Silent(VARIANT_TRUE);//禁止脚本错误提示  
	
	//在不同dpi的情况下,使用相同大小的显示
	if (m_iWidth > 0 && m_iHeight > 0)
	{
		SetWindowPos(NULL, 0, 0, m_iWidth, m_iHeight, SWP_NOMOVE);
	}

	if (m_dialogTitle.GetLength() > 0) SetWindowText(m_dialogTitle);

	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
开发者ID:a3587556,项目名称:trochilus,代码行数:54,代码来源:HTMLContainerDlg.cpp

示例4: reportError

void reportError(
	int errorType, LPUNKNOWN pIUnknown, const char * pszMessage )
{
	HRESULT rc;
	assert( pIUnknown != NULL );

	IDgnErrorPtr pIDgnError;
	rc = pIUnknown->QueryInterface(
		__uuidof(IDgnError), (void**)&pIDgnError );
	if( FAILED(rc) )
	{
		reportError( errorType, pszMessage );
		return;
	}

	char szNatSpeakErr[ 512 ];
	DWORD dwSizeNeeded;
	rc = pIDgnError->ErrorMessageGet( szNatSpeakErr, 512, &dwSizeNeeded );
	if( rc != E_BUFFERTOOSMALL && FAILED(rc) )
	{
		reportError( errorType, pszMessage );
		return;
	}

	char szErrorMsg[ 1024 ];
	sprintf( szErrorMsg, "%s (%s)", pszMessage, szNatSpeakErr );
	PyErr_SetString( ErrObjects[errorType], szErrorMsg );
}
开发者ID:merrillh,项目名称:aenea,代码行数:28,代码来源:excepts.cpp

示例5: _AfxLoadObjectFromStreamedPropset

BOOL AFXAPI _AfxLoadObjectFromStreamedPropset(LPUNKNOWN lpUnknown, LPSTREAM lpStream)
{
	ASSERT_POINTER(lpUnknown, IUnknown);
	ASSERT_POINTER(lpStream, IStream);

	BOOL bSuccess = FALSE;
	LPDATAOBJECT pDataObj = NULL;

	if (SUCCEEDED(lpUnknown->QueryInterface(IID_IDataObject,
			(LPVOID*)&pDataObj)))
	{
		ASSERT_POINTER(pDataObj, IDataObject);

		// Set the persistent propset format on the object.

		FORMATETC formatEtc;
		STGMEDIUM stgMedium;
		formatEtc.cfFormat = _AfxGetClipboardFormatPersistPropset();
		formatEtc.ptd = NULL;
		formatEtc.dwAspect = DVASPECT_CONTENT;
		formatEtc.lindex = -1;
		formatEtc.tymed = TYMED_ISTREAM;

		stgMedium.tymed = TYMED_ISTREAM;
		stgMedium.pstm = lpStream;
		stgMedium.pUnkForRelease = NULL;

		bSuccess = SUCCEEDED(pDataObj->SetData(&formatEtc, &stgMedium, FALSE));

		pDataObj->Release();
	}

	return bSuccess;
}
开发者ID:anyue100,项目名称:winscp,代码行数:34,代码来源:ctlpset.cpp

示例6: CDialog

CDlgIADsPropertyList::CDlgIADsPropertyList(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
    : CDialog(CDlgIADsPropertyList::IDD, pParent)
{
    //{{AFX_DATA_INIT(CDlgIADsPropertyList)
    m_sAttribute = _T("");
    //}}AFX_DATA_INIT

    HRESULT hr;
    m_pPropList = NULL;
    hr = pUnk->QueryInterface( IID_IADsPropertyList, (void **) &m_pPropList );
    if ( !SUCCEEDED(hr) )
    {
        AfxMessageBox(_T("Fatal Error! QI for IADsPropertyList failed"));
        return;
    }
    pUnk->Release();


    //////////////////////////////////////////
    // Retrieve the data to the cache
    ////////////////////////////////////////////
    IADs *pADs=NULL;
    hr = m_pPropList->QueryInterface( IID_IADs, (void**) &pADs );
    if ( SUCCEEDED(hr) )
    {
        hr = pADs->GetInfo();
        pADs->Release();
    }



}
开发者ID:dgrapp1,项目名称:WindowsSDK7-Samples,代码行数:32,代码来源:ADsPropertyList.cpp

示例7: LoadFromMoniker

void CMFCBindCntrItem::LoadFromMoniker(LPUNKNOWN pUnk, OLECHAR* szwName)
{
	HRESULT hr;
	// Ask the system for a URL Moniker
	IMoniker* pIMoniker;
	hr = CreateURLMoniker(NULL, (LPWSTR)szwName, &pIMoniker);
	if ( SUCCEEDED(hr) )
	{
		// Get the IPersistMoniker interface
		IPersistMoniker* pPMk;
		hr = pUnk->QueryInterface(
								IID_IPersistMoniker,
								(void **)&pPMk);
		if ( SUCCEEDED(hr) )
		{
				// note: do not register our BSC when calling IPM::Load directly
			IBindCtx *pBCtx;
			hr = CreateBindCtx(0, &pBCtx);
			if ( SUCCEEDED(hr) )
			{
				// Call Load on the IPersistMoniker
				hr = pPMk->Load(FALSE, pIMoniker, pBCtx, STGM_READ);
					pBCtx->Release();
			}
			pPMk->Release();
		}
		pIMoniker->Release( );
	}
}
开发者ID:Jinjiego,项目名称:VCSamples,代码行数:29,代码来源:CntrItem.cpp

示例8: CDialog

CDlgIDirectoryObject::CDlgIDirectoryObject(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIDirectoryObject::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIDirectoryObject)
	m_sDN = _T("");
	m_sRDN = _T("");
	m_sSchema = _T("");
	m_sClass = _T("");
	m_sParent = _T("");
	m_sAttributes = _T("");
	//}}AFX_DATA_INIT

	HRESULT hr;
	m_pDirObject = NULL;
	hr = pUnk->QueryInterface( IID_IDirectoryObject, (void **) &m_pDirObject );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IDirectoryObject failed"));
		return;
	}
	pUnk->Release();

	ShowAttributes();

}
开发者ID:AbdoSalem95,项目名称:WindowsSDK7-Samples,代码行数:25,代码来源:DirectoryObject.cpp

示例9: CDialog

CDlgIADs::CDlgIADs(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIADs::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIADs)
	m_sADsPath = _T("");
	m_sClass = _T("");
	m_sName = _T("");
	m_sParent = _T("");
	m_sSchema = _T("");
	m_sGUID = _T("");
	//}}AFX_DATA_INIT

	///////////////////////////////////////
	// Get the IADs pointer and save it 
	/////////////////////////////////////
	HRESULT hr;
	m_pADs = NULL;
	hr = pUnk->QueryInterface( IID_IADs, (void **) &m_pADs );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IADs failed"));
		return;
	}
	pUnk->Release();
	

}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:27,代码来源:ADs.cpp

示例10: OnCreate

int CTemplateWizardDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (TEMPLATE_WIZARD_DIALOG::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	AfxEnableControlContainer();

	// create the control window
	// AFX_IDW_PANE_FIRST is a safe but arbitrary ID
	if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, "",
				WS_VISIBLE | WS_CHILD, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST))
	{
		DestroyWindow();
		return FALSE;
	}

	LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown();
	HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp);
	if (!SUCCEEDED(hr))
	{
		m_pBrowserApp = NULL;
		m_wndBrowser.DestroyWindow();
		DestroyWindow();
		return FALSE;
	}

	return 0;
}
开发者ID:Luomu,项目名称:workspacewhiz,代码行数:28,代码来源:TemplateWizardDialog.cpp

示例11: OnView

HRESULT CDataObjectViewer::OnView(HWND hwndParent, REFIID riid, LPUNKNOWN punk)
{
	SCODE sc = NOERROR ;

	ASSERT(hwndParent);
	ENSURE(punk);

	if (riid != IID_IDataObject)
	{
		AfxMessageBox( _T("IDataObject interface viewer only supports IID_IDataObject") ) ;
		return E_INVALIDARG ;
	}

	IDataObject* pdataobj = NULL ;
	sc = punk->QueryInterface( riid, (void**)&pdataobj ) ;
	if (FAILED(sc))
	{
		AfxMessageBox( _T("Object does not support IDataObject") ) ;
		return E_UNEXPECTED ;
	}

	CIDataObjectDlg* pdlg ;
	pdlg = new CIDataObjectDlg( hwndParent, pdataobj, riid, _T("") ) ;

	if (pdlg)
	{
		pdlg->DoModal() ;
		delete pdlg ;
	}

	pdataobj->Release() ;

	return sc ;
}
开发者ID:Jinjiego,项目名称:VCSamples,代码行数:34,代码来源:dataobj.cpp

示例12: CDialog

CDlgIDirectorySearch::CDlgIDirectorySearch(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIDirectorySearch::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIDirectorySearch)
	m_sFilter = _T("");
	m_bEnableFilter = FALSE;
	m_nTimeOut = 0;
	m_bCacheResult = FALSE;
	m_nPageSize = 0;
	m_sSortOn = _T("");
	m_nTimeLimit = 0;
	m_nSizeLimit = 0;
	m_bAsynch = FALSE;
	m_bAttrib = FALSE;
	m_nDeref = -1;
	//}}AFX_DATA_INIT
	HRESULT hr;
	m_pSearch = NULL;
	hr = pUnk->QueryInterface( IID_IDirectorySearch, (void **) &m_pSearch );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IDirectorySearch failed"));
		return;
	}
	pUnk->Release();



}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:29,代码来源:DirectorySearch.cpp

示例13: Create

BOOL SimpleBrowser::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
    // create browser control window as child of this window; 
	// this window sinks events from control
	//BOOL results = CWnd::Create(AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW),
	//                         NULL,
	//						 dwStyle,
	//						 rect,
	//						 pParentWnd,
	//						 nID);
	BOOL results = CWnd::Create(_T("#32770"),
		NULL,
		dwStyle,
		rect,
		pParentWnd,
		nID);
    if (!results) 
		return FALSE;
	//create the original window
	m_pBrowserWnd = new CWnd;
    results = m_pBrowserWnd->CreateControl(CLSID_WebBrowser, NULL, (WS_VISIBLE | WS_TABSTOP),
		CRect(0,0,rect.right - rect.left,rect.bottom - rect.top), this, AFX_IDW_PANE_FIRST);
    if (!results) 
	{
        DestroyWindow();
        return FALSE;
    }
    // get control interfaces
	m_pBrowser = NULL;
    LPUNKNOWN pUnknown = m_pBrowserWnd->GetControlUnknown();
	HRESULT hr = S_FALSE;
	if (pUnknown != NULL)
	{
		hr = pUnknown->QueryInterface(IID_IWebBrowser2,(void **)&m_pBrowser);
		if (SUCCEEDED(hr)) 
			hr = pUnknown->QueryInterface(IID_IDispatch,(void **)&m_pBrowserDispatch);
	}
    if (!SUCCEEDED(hr)) {
        m_pBrowserWnd->DestroyWindow();
		delete m_pBrowserWnd;
		m_pBrowserWnd = NULL;
        DestroyWindow();
        return FALSE;        
    }
    return TRUE;
}
开发者ID:ddavison,项目名称:Jaangle,代码行数:46,代码来源:SimpleBrowser.cpp

示例14: GetItemInfo

STDMETHODIMP ActiveScriptImpl::GetItemInfo(
			/* [in] */ LPCOLESTR pstrName,
			/* [in] */ DWORD dwReturnMask,
			/* [out] */LPUNKNOWN* ppiunkItem,
			/* [out] */LPTYPEINFO* ppti)
{
	if (dwReturnMask & SCRIPTINFO_ITYPEINFO)
	{
		if (!ppti)
			return E_INVALIDARG;
		*ppti = NULL;
	}

	if (dwReturnMask & SCRIPTINFO_IUNKNOWN)
	{
		if (!ppiunkItem)
			return E_INVALIDARG;
		*ppiunkItem = NULL;
	}

	LPUNKNOWN lpUnknown = namedItems.get(pstrName);
	if (NULL == lpUnknown)
	{
		ATLTRACE("No IUnknown for item!\n");
		// This shouldn't ever happen, since we're providing the items
		return TYPE_E_ELEMENTNOTFOUND;
	}

	if (dwReturnMask & SCRIPTINFO_ITYPEINFO)
	{
		// Use IProvideClassInfo to get ITypeInfo of coclass!
		IProvideClassInfo *pci = NULL;
		HRESULT hr = lpUnknown->QueryInterface(IID_IProvideClassInfo, (void**)&pci);
		if (SUCCEEDED(hr) && pci)
		{
			hr = pci->GetClassInfo(ppti);
		}

		// Release interface
		if (pci)
			pci->Release();

		if (FAILED(hr))
			return E_FAIL;
	}

	if (dwReturnMask & SCRIPTINFO_IUNKNOWN)
	{
		*ppiunkItem = lpUnknown;
		int *pInt = weakItems.get(pstrName);
		if (!pInt)
			(*ppiunkItem)->AddRef();    // because returning
		else
			*pInt = (*pInt) + 1;
	}

	return S_OK;
}
开发者ID:Templier,项目名称:desktopx,代码行数:58,代码来源:ActiveScriptImpl.cpp

示例15: _AfxQueryInterface

LPUNKNOWN AFXAPI _AfxQueryInterface(LPUNKNOWN lpUnknown, REFIID iid)
{
	ASSERT(lpUnknown != NULL);

	LPUNKNOWN lpW = NULL;
	if (lpUnknown->QueryInterface(iid, (LPLP)&lpW) != S_OK)
		return NULL;

	return lpW;
}
开发者ID:Rupan,项目名称:winscp,代码行数:10,代码来源:oleunk.cpp


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