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


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

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


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

示例1: AfxDllGetClassObject

SCODE AFXAPI AfxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    SCODE sc;
    *ppv = NULL;

    AFX_OLE_STATE* pOleState = AfxGetOleState();
    // search factories defined in the application
    for (COleObjectFactory* pFactory = pOleState->m_pFirstFactory;
            pFactory != NULL; pFactory = pFactory->m_pNextFactory)
    {
        if (pFactory->m_dwRegister != 0 && pFactory->m_clsid == rclsid)
        {
            // found suitable class factory -- query for correct interface
            sc = pFactory->ExternalQueryInterface(&riid, ppv);
            if (sc != NOERROR)
                return sc;
#ifndef _UNICODE
            LPUNKNOWN lpUnk = (LPUNKNOWN)*ppv;
            ASSERT(lpUnk != NULL);
            sc = ::Ole2AnsiWFromA(riid, lpUnk, (LPUNKNOWN*)ppv);
            lpUnk->Release();
#endif
            return sc;
        }
    }
#ifdef _AFXDLL
    // search factories defined in extension DLLs
    AFX_CORE_STATE* pCoreState = AfxGetCoreState();
    for (CDynLinkLibrary* pDLL = pCoreState->m_pFirstDLL; pDLL != NULL;
            pDLL = pDLL->m_pNextDLL)
    {
        for (pFactory = pDLL->m_pFirstSharedFactory;
                pFactory != NULL; pFactory = pFactory->m_pNextFactory)
        {
            if (pFactory->m_dwRegister != 0 && pFactory->m_clsid == rclsid)
            {
                // found suitable class factory -- query for correct interface
                sc = pFactory->ExternalQueryInterface(&riid, ppv);
                if (sc != NOERROR)
                    return sc;
#ifndef _UNICODE
                LPUNKNOWN lpUnk = (LPUNKNOWN)*ppv;
                ASSERT(lpUnk != NULL);
                sc = ::Ole2AnsiWFromA(riid, lpUnk, (LPUNKNOWN*)ppv);
                lpUnk->Release();
#endif
                return sc;
            }
        }
    }
#endif

    // factory not registered -- return error
    return CLASS_E_CLASSNOTAVAILABLE;
}
开发者ID:shuowen,项目名称:OpenNT,代码行数:55,代码来源:oledll.cpp

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

示例3: EnumerateInterface

void CADQIDlg::EnumerateInterface()
{
    int xx=0;
    HRESULT hr;
    LPUNKNOWN pQI;

    m_cListIf.ResetContent();

    ///////////////////////////////////////////////////////////////
    // Query Interface all known ADSI Interfaces
    ////////////////////////////////////////////////////////////////
    while( !IsEqualIID( *adsiIfs[xx].pIID, IID_NULL ) )
    {
        hr = m_pUnk->QueryInterface( *adsiIfs[xx].pIID, (void**) &pQI );
        if ( SUCCEEDED(hr) )
        {
            m_cListIf.AddString( adsiIfs[xx].szIf );
            pQI->Release();
        }
        xx++;
    }



}
开发者ID:dbremner,项目名称:Windows-classic-samples,代码行数:25,代码来源:ADQIDlg.cpp

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

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

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

示例7: CreateDispatch

BOOL IXArrayDB::CreateDispatch(REFCLSID clsid, COleException* pError )
{
   ASSERT(m_lpDispatch == NULL);

   m_bAutoRelease = TRUE;  // good default is to auto-release

   // create an instance of the object
   LPUNKNOWN lpUnknown = NULL;
   HRESULT sc = CreateInstanceLic( this->GetCLSID(), NULL,
                                   CLSCTX_ALL | CLSCTX_REMOTE_SERVER,
                                   IID_IUnknown, (zPVOID*)&lpUnknown);
   if (sc == E_INVALIDARG)
   {
      // may not support CLSCTX_REMOTE_SERVER, so try without
      sc = CreateInstanceLic(this->GetCLSID(), NULL, CLSCTX_ALL & ~CLSCTX_REMOTE_SERVER,
         IID_IUnknown, (zPVOID*)&lpUnknown);
   }
   if (FAILED(sc))
      goto Failed;

   // make sure it is running
   sc = OleRun(lpUnknown);
   if (FAILED(sc))
      goto Failed;

   // query for IDispatch interface
   sc = lpUnknown->QueryInterface( IID_IDispatch, (zPVOID*) &m_lpDispatch);
   if (m_lpDispatch == NULL)
      goto Failed;

   lpUnknown->Release();
   ASSERT(m_lpDispatch != NULL);
   return TRUE;

Failed:
   lpUnknown->Release();
   if (pError != NULL)
      pError->m_sc = sc;
   TRACE1("Warning: CreateDispatch returning scode = %s.\n",
      AfxGetFullScodeString(sc));
   return FALSE;
}
开发者ID:DeegC,项目名称:10d,代码行数:42,代码来源:xarraydb.cpp

示例8: ErrorHandle

DLLEXPORT double MADX9_FreePointer(double p)
{
	LPUNKNOWN ptr = (LPUNKNOWN) DoubleToPtr(p);

	if (ptr == 0)
		return ErrorHandle(mamain->err, ErrorInv);

	ptr->Release();

	return ErrorOk;
}
开发者ID:gitter-badger,项目名称:MA-Engine,代码行数:11,代码来源:MA_Misc.cpp

示例9: GetStartPosition

CConnectionPoint::~CConnectionPoint()
{
	POSITION pos = GetStartPosition();
	while (pos != NULL)
	{
		LPUNKNOWN pUnk = GetNextConnection(pos);
		ASSERT(pUnk != NULL);
		pUnk->Release();
	}

	if (m_pConnections != NULL)
		delete m_pConnections;
}
开发者ID:anyue100,项目名称:winscp,代码行数:13,代码来源:oleconn.cpp

示例10: OnSortDesc

void CDataGridEx::OnSortDesc()
{
	CString strTemp;
	_RecordsetPtr IRecordset;
	LPUNKNOWN pUnknown;
	HRESULT hr;

	try
	{
		pUnknown=this->GetDataSource();

		hr=pUnknown->QueryInterface(__uuidof(_RecordsetPtr),(void**)&IRecordset);

		if(FAILED(hr))
		{
			pUnknown->Release();
			AfxMessageBox(_com_error(hr).ErrorMessage());
			return;
		}

		pUnknown->Release();

		strTemp=GetColumns().GetItem(_variant_t(m_SelectCol)).GetCaption();

		strTemp+=_T(" DESC");
		IRecordset->Sort=_bstr_t(strTemp);
	}
	catch (_com_error &e)
	{
		CString strMsg;
		strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
		AfxMessageBox(strMsg);
	}

	
	return;
}
开发者ID:uesoft,项目名称:AutoPHS,代码行数:37,代码来源:DataGridEx.cpp

示例11: OnInitDialog

BOOL CDriverDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// create the calculator object that we'll drive through OLE automation
	COleException e;
	CLSID clsid;
	if (CLSIDFromProgID(OLESTR("mfccalc.calculator"), &clsid) != NOERROR)
	{
		AfxMessageBox(IDP_UNABLE_TO_CREATE);
		EndDialog(IDABORT);
		return FALSE;
	}

	// try to get the active calculator before creating a new one
	LPUNKNOWN lpUnk;
	LPDISPATCH lpDispatch;
	if (GetActiveObject(clsid, NULL, &lpUnk) == NOERROR)
	{
		HRESULT hr = lpUnk->QueryInterface(IID_IDispatch,
			(LPVOID*)&lpDispatch);
		lpUnk->Release();
		if (hr == NOERROR)
			m_calc.AttachDispatch(lpDispatch, TRUE);
	}

	// if not dispatch ptr attached yet, need to create one
	if (m_calc.m_lpDispatch == NULL &&
		!m_calc.CreateDispatch(clsid, &e))
	{
		AfxMessageBox(IDP_UNABLE_TO_CREATE);
		EndDialog(IDABORT);
		return FALSE;
	}

	// attempt to make it visible
	m_calc.SetVisible(TRUE);
	if (!m_calc.GetVisible())
	{
		AfxMessageBox(IDP_UNABLE_TO_SHOW);
		EndDialog(IDABORT);
		return FALSE;
	}

	// refresh display to contents of the automation calculator
	OnRefresh();

	return TRUE;  // return TRUE  unless you set the focus to a control
}
开发者ID:jetlive,项目名称:skiaming,代码行数:49,代码来源:calcdriv.cpp

示例12: InitToolTipControl

////////////////////////////////////////////////
//
// 初始化TOOLTIP控件
//
void CDataGridEx::InitToolTipControl()
{
	if(m_RecordCount<0)
	{
		LPUNKNOWN pUnknown;
		HRESULT hr;
		_RecordsetPtr IRecordset;

		pUnknown=GetDataSource();
		
		if(pUnknown==NULL)
			return;

		try
		{
			hr=pUnknown->QueryInterface(__uuidof(Recordset),(void**)&IRecordset);

			pUnknown->Release();

			if(FAILED(hr))
			{
				throw _com_error(hr);
			}

			m_RecordCount=IRecordset->GetRecordCount();
		}
		catch(_com_error &e)
		{
			AfxMessageBox(e.ErrorMessage());
		}
	}

	if(IsWindow(m_ToolTip.GetSafeHwnd()))
		return;

	m_ToolTip.Create(this);
	
	TOOLINFO ToolInfo;

	memset(&ToolInfo,0,sizeof(TOOLINFO));

	ToolInfo.cbSize=sizeof(TOOLINFO);
	ToolInfo.uFlags=TTF_TRACK|TTF_IDISHWND| TTF_ABSOLUTE;
	ToolInfo.hwnd=this->m_hWnd;
	ToolInfo.uId=(UINT)this->m_hWnd;
	ToolInfo.lpszText=LPSTR_TEXTCALLBACK;

	m_ToolTip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&ToolInfo);
}
开发者ID:uesoft,项目名称:AutoPHS,代码行数:53,代码来源:DataGridEx.cpp

示例13: UnregisterMsgSource

/**
 * Function name	CImplMsgSink::UnregisterMsgSource
 * Description			
 * @param			LPUNKNOWN lpUnkMsgSource
 * @param			DWORD dwCookie
 * @return			HRESULT 
 * @exception			
 * @see			    CMsgWnd
*/
HRESULT CImplMsgSink::UnregisterMsgSource(LPUNKNOWN lpUnkMsgSource, DWORD dwCookie) 
{
    ASSERT(lpUnkMsgSource != NULL);

    LPUNKNOWN           pUnkSink;
    BOOL                bResult;

    HRESULT hr = InternalQueryInterface((IID*)&IID_IUnknown, (void**)&pUnkSink);
    if(FAILED(hr)) 
    {
        return(hr);
    }

    bResult = AfxConnectionUnadvise(lpUnkMsgSource, IID__ICEMessageEvent, pUnkSink, TRUE, dwCookie);
    pUnkSink->Release();
    return(bResult ? S_OK : E_FAIL);
}
开发者ID:LM25TTD,项目名称:ATCMcontrol_Engineering,代码行数:26,代码来源:ImplMsgSink.cpp

示例14: CreateDispatch

BOOL COleDispatchDriver::CreateDispatch(REFCLSID clsid, COleException* pError)
{
	ASSERT(m_lpDispatch == NULL);

	m_bAutoRelease = TRUE;  // good default is to auto-release

	// create an instance of the object
	LPUNKNOWN lpUnknown = NULL;
	SCODE sc = CoCreateInstance(clsid, NULL, CLSCTX_ALL | CLSCTX_REMOTE_SERVER,
		IID_IUnknown, (LPLP)&lpUnknown);
	if (sc == E_INVALIDARG)
	{
		// may not support CLSCTX_REMOTE_SERVER, so try without
		sc = CoCreateInstance(clsid, NULL, CLSCTX_ALL & ~CLSCTX_REMOTE_SERVER,
			IID_IUnknown, (LPLP)&lpUnknown);
	}
	if (FAILED(sc))
		goto Failed;

	// make sure it is running
	sc = OleRun(lpUnknown);
	if (FAILED(sc))
		goto Failed;

	// query for IDispatch interface
	m_lpDispatch = QUERYINTERFACE(lpUnknown, IDispatch);
	if (m_lpDispatch == NULL)
		goto Failed;

	lpUnknown->Release();
	ASSERT(m_lpDispatch != NULL);
	return TRUE;

Failed:
	RELEASE(lpUnknown);
	if (pError != NULL)
		pError->m_sc = sc;
	TRACE1("Warning: CreateDispatch returning scode = %s.\n",
		AfxGetFullScodeString(sc));
	return FALSE;
}
开发者ID:cyb3727,项目名称:annrecognition,代码行数:41,代码来源:OleDispatchDriver.cpp

示例15:

/* Return the MAPI message object of then inspector from a button's
   instance id. */
static LPMESSAGE
get_message_from_button (unsigned long instid, LPDISPATCH *r_inspector)
{
  HRESULT hr;
  LPDISPATCH inspector, obj;
  LPUNKNOWN  unknown;
  LPMESSAGE message = NULL;
  
  if (r_inspector)
    *r_inspector = NULL;
  inspector = get_inspector_from_instid (instid);
  if (inspector)
    {
      obj = get_oom_object (inspector, "get_CurrentItem");
      if (!obj)
        log_error ("%s:%s: error getting CurrentItem", SRCNAME, __func__);
      else
        {
          unknown = get_oom_iunknown (obj, "MAPIOBJECT");
          if (!unknown)
            log_error ("%s:%s: error getting MAPI object", SRCNAME, __func__);
          else
            {
              hr = unknown->QueryInterface (IID_IMessage, (void**)&message);
              if (hr != S_OK || !message)
                {
                  message = NULL;
                  log_error ("%s:%s: error getting IMESSAGE: hr=%#lx",
                             SRCNAME, __func__, hr);
                }
              unknown->Release ();
            }
          obj->Release ();
        }
      if (r_inspector)
        *r_inspector = inspector;
      else
        inspector->Release ();
    }
  return message;
}
开发者ID:gpg,项目名称:gpgol,代码行数:43,代码来源:inspectors.cpp


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