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


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

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


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

示例1: PyCom_BuildPyException

// @pymethod |PyICreateTypeInfo|AddRefTypeInfo|Description of AddRefTypeInfo.
PyObject *PyICreateTypeInfo::AddRefTypeInfo(PyObject *self, PyObject *args)
{
	ICreateTypeInfo *pICTI = GetI(self);
	if ( pICTI == NULL )
		return NULL;
	// @pyparm <o PyITypeInfo>|pTInfo||Description for pTInfo
	PyObject *obpTInfo;
	ITypeInfo * pTInfo;
	if ( !PyArg_ParseTuple(args, "O:AddRefTypeInfo", &obpTInfo) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpTInfo, IID_ITypeInfo, (void **)&pTInfo, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	HREFTYPE hRefType;
	PY_INTERFACE_PRECALL;
	hr = pICTI->AddRefTypeInfo( pTInfo, &hRefType );
	if (pTInfo) pTInfo->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICTI, IID_ICreateTypeInfo);
	return PyInt_FromLong(hRefType);
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:26,代码来源:PyICreateTypeInfo.cpp

示例2: GetTypeInfo

STDMETHODIMP
CMediaPosition::Invoke(
  DISPID dispidMember,
  REFIID riid,
  LCID lcid,
  WORD wFlags,
  DISPPARAMS * pdispparams,
  VARIANT * pvarResult,
  EXCEPINFO * pexcepinfo,
  UINT * puArgErr)
{
    // this parameter is a dead leftover from an earlier interface
    if (IID_NULL != riid) {
	return DISP_E_UNKNOWNINTERFACE;
    }

    ITypeInfo * pti;
    HRESULT hr = GetTypeInfo(0, lcid, &pti);

    if (FAILED(hr)) {
	return hr;
    }

    hr = pti->Invoke(
	    (IMediaPosition *)this,
	    dispidMember,
	    wFlags,
	    pdispparams,
	    pvarResult,
	    pexcepinfo,
	    puArgErr);

    pti->Release();
    return hr;
}
开发者ID:HackLinux,项目名称:Free-Download-Manager-vs2010,代码行数:35,代码来源:ctlutil.cpp

示例3:

static PyObject *PyRecord_reduce(PyObject *self, PyObject *args)
{
	PyObject *ret = NULL;
	PyRecord *pyrec = (PyRecord *)self;
	PyObject *obModule = NULL, *obModDict = NULL, *obFunc = NULL;
	ITypeInfo *pti = NULL;
	TYPEATTR *pta = NULL;
	ULONG cb;
	HRESULT hr;
	GUID structguid;
	if (!PyArg_ParseTuple(args, ":reduce"))
		return NULL;
	hr = pyrec->pri->GetTypeInfo(&pti);
	if (FAILED(hr)||pti==NULL) {
		PyCom_BuildPyException(hr);
		goto done;
	}
	hr = pti->GetTypeAttr(&pta);
	if (FAILED(hr)||pta==NULL) {
		PyCom_BuildPyException(hr);
		goto done;
	}
	hr = pyrec->pri->GetGuid(&structguid);
	if (FAILED(hr)) {
		PyCom_BuildPyException(hr);
		goto done;
	}
	hr = pyrec->pri->GetSize(&cb);
	if (FAILED(hr)) {
		PyCom_BuildPyException(hr);
		goto done;
	}
	obModule = PyImport_ImportModule("pythoncom");
	if (obModule)
		obModDict = PyModule_GetDict(obModule); // no ref added!
	if (obModDict)
		obFunc = PyDict_GetItemString(obModDict, "GetRecordFromGuids"); // no ref added!
	if (!obFunc) {
		PyErr_Clear();
		PyErr_SetString(PyExc_RuntimeError, "pythoncom.GetRecordFromGuids() can't be located!");
		goto done;
	}
	ret = Py_BuildValue("O(NHHiNN)",
						obFunc,
						PyWinObject_FromIID(pta->guid),
						pta->wMajorVerNum,
						pta->wMinorVerNum,
						pta->lcid,
						PyWinObject_FromIID(structguid),
						PyString_FromStringAndSize((char *)pyrec->pdata, cb));

done:
	if (pta&& pti)
		pti->ReleaseTypeAttr(pta);
	if (pti) pti->Release();
	Py_XDECREF(obModule);
	// obModDict and obFunc have no new reference.
	return ret;
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:59,代码来源:PyRecord.cpp

示例4: getFUNCDESC

bool tLuaCOM::getFUNCDESC(const char *name, FuncInfo& funcinfo)
{
  // First, tries to see we have the FUNCDESC's cached

  long counter = 0;

  for(counter = 0; counter < MAX_FUNCINFOS; counter++)
  {
    // when .name is NULL, there is no further information
    if(pFuncInfo[counter].name == NULL)
      break;

    if(strcmp(name, pFuncInfo[counter].name) == 0)
      break;
  }

  // checks whether funcinfo was found
  if(counter < MAX_FUNCINFOS && pFuncInfo[counter].name != NULL)
  {
    funcinfo = pFuncInfo[counter];
    return true;
  }

  // did not find, so gets type information through
  // ITypeComp

  HRESULT hr = S_OK;
  BINDPTR bindptr;
  DESCKIND desckind;
  BSTR wName;
  ITypeInfo *info = NULL;

  unsigned int dumb = 0;

  wName = tUtil::string2bstr(name);

  unsigned long lhashval = LHashValOfName(LOCALE_SYSTEM_DEFAULT, wName);

  hr = ptcomp->Bind(wName, lhashval, INVOKE_PROPERTYGET,
    &info, &desckind, &bindptr);
  
  if(FAILED(hr) || desckind == DESCKIND_NONE)
    funcinfo.propget = NULL;
  else
  {
    funcinfo.propget = bindptr.lpfuncdesc;
    info->Release();
  }

  hr = ptcomp->Bind(wName, lhashval, INVOKE_FUNC,
    &info, &desckind, &bindptr);
  
  if(FAILED(hr) || desckind == DESCKIND_NONE)
    funcinfo.func = NULL;
  else
  {
    funcinfo.func = bindptr.lpfuncdesc;
    info->Release();
  }


  hr = ptcomp->Bind(wName, lhashval, INVOKE_PROPERTYPUT,
    &info, &desckind, &bindptr);
  
  if(FAILED(hr) || desckind == DESCKIND_NONE)
    funcinfo.propput = NULL;
  else
  {
    funcinfo.propput = bindptr.lpfuncdesc;
    info->Release();
  }

  // if there is not propertyput, then tries propputref

  if(funcinfo.propput == NULL)
  {
    hr = ptcomp->Bind(wName, lhashval, INVOKE_PROPERTYPUTREF,
      &info, &desckind, &bindptr);

    if(FAILED(hr) || desckind == DESCKIND_NONE)
      funcinfo.propput = NULL;
    else
    {
      funcinfo.propput = bindptr.lpfuncdesc;
      info->Release();
    }
  }

  SysFreeString(wName);

  // If no type information found, returns NULL
  if(!funcinfo.propget && !funcinfo.propput && !funcinfo.func)
    return false;
  else if(counter < MAX_FUNCINFOS)
  {
    CHECKPRECOND(pFuncInfo[counter].name == NULL);

    pFuncInfo[counter].name = tUtil::strdup(name);

    pFuncInfo[counter].propget  = funcinfo.propget;
//.........这里部分代码省略.........
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:101,代码来源:tLuaCOM.cpp

示例5: ITypeCompBind

static PyObject* ITypeCompBind( ITypeComp* pTC, OLECHAR* S, unsigned short w )
{
	ITypeInfo*		pI;
	DESCKIND  		DK;
	BINDPTR			BP;
	PyObject*		ret;
	unsigned long	hashval = 0;
	PY_INTERFACE_PRECALL;
#ifndef MS_WINCE
	// appears in the headers for CE, but wont link!?
	hashval = LHashValOfNameSys(SYS_WIN32,LOCALE_USER_DEFAULT,S);
#endif
	SCODE sc = pTC->Bind(S, hashval,w, &pI, &DK, &BP);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc);
	switch(DK){
		case DESCKIND_FUNCDESC:
			ret = PyObject_FromFUNCDESC(BP.lpfuncdesc);
			pI->ReleaseFuncDesc(BP.lpfuncdesc);
			break;
		case DESCKIND_VARDESC:
			ret = PyObject_FromVARDESC(BP.lpvardesc);
			pI->ReleaseVarDesc(BP.lpvardesc);
			break;
		case DESCKIND_TYPECOMP:
			ret = PyCom_PyObjectFromIUnknown(BP.lptcomp, IID_ITypeComp, FALSE);
			break;
		case DESCKIND_IMPLICITAPPOBJ:
			ITypeComp* pTC2;
			pI->GetTypeComp(&pTC2);
			ret = PyTuple_New(2);
			if (ret) {
				// NOTE: SET_ITEM consumes the refcounts.
				PyTuple_SET_ITEM( ret, 0, PyObject_FromVARDESC(BP.lpvardesc) );
				PyTuple_SET_ITEM( ret, 1, ITypeCompBind(pTC2,S,w) );
			}
			pTC2->Release();
			pI->ReleaseVarDesc(BP.lpvardesc);
			break;

		case DESCKIND_NONE:
		default:
			Py_INCREF(Py_None);
			ret = Py_None;
			break;
		}
	if (pI)
		pI->Release();
	if (ret == NULL)
		return NULL;
	PyObject *real_ret = PyTuple_New(2);
	if (real_ret==NULL)
		return NULL;
	// NOTE: SET_ITEM consumes the refcounts.
	PyTuple_SET_ITEM(real_ret, 0, PyInt_FromLong(DK) );
	PyTuple_SET_ITEM(real_ret, 1, ret );
	return real_ret;
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:59,代码来源:PyIType.cpp

示例6: PrintTInfo

HRESULT PrintTInfo(ITypeInfo* pTinfo, int indentation){
	TYPEATTR* pTypeAttr;
	HRESULT hr = pTinfo->GetTypeAttr(&pTypeAttr); COMRet(hr);
	for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT("    "); 
	LPOLESTR guid_str;
	hr = StringFromCLSID(pTypeAttr->guid, &guid_str);
	std::wcout<<guid_str<<std::endl;

	// Inherited Interfaces, therefore we recursively call PrintInfo
	for(int i = 0; i != pTypeAttr->cImplTypes; ++i){
		HREFTYPE RefType;
		hr = pTinfo->GetRefTypeOfImplType(i, &RefType); COMRet(hr);
		ITypeInfo* pImplTinfo;
		hr = pTinfo->GetRefTypeInfo(RefType, &pImplTinfo); COMRet(hr);
		hr = PrintTInfo(pImplTinfo, indentation + 1); if(hr != S_OK && hr != TYPE_E_BADMODULEKIND) return hr; // Because this ITypeInfo is retrieved
		pImplTinfo->Release();                                                                                // directly from a .tlb file instead
		                                                                                                      // of a .dll, AddressofMember fails
	}

	//member functions
	for(int i = 0; i != pTypeAttr->cFuncs; ++i){
		FUNCDESC* pFuncDesc;
		hr = pTinfo->GetFuncDesc(i, &pFuncDesc); COMRet(hr);
		const UINT cMaxNames = 10; UINT cNames;
		BSTR rgBstrNames[cMaxNames];
		hr = pTinfo->GetNames(pFuncDesc->memid, rgBstrNames, cMaxNames, &cNames); COMRet(hr);
		void* pv;
		hr = pTinfo->AddressOfMember(pFuncDesc->memid, pFuncDesc->invkind, &pv); if(hr != S_OK && hr != TYPE_E_BADMODULEKIND) return hr;
		for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT("    ");
		std::wcout<<TEXT("Func memid = ")<<pFuncDesc->memid<<TEXT(" Name = ")<<*rgBstrNames<<TEXT(" DllAddress = ")<<pv<<std::endl;
		for(int j = 0; j != pFuncDesc->cParams; ++j){
			TCHAR szBuffer[30];
			wParamFlagsTranslate(pFuncDesc->lprgelemdescParam->paramdesc.wParamFlags, szBuffer, 30);
			for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT("    ");
			std::wcout<<TEXT(" ")<<szBuffer<<TEXT(" ")<<*(rgBstrNames+j+1)<<TEXT(": ")<<std::endl;
			TExpandPointer(pFuncDesc->lprgelemdescParam->tdesc, 2);
		}
		pTinfo->ReleaseFuncDesc(pFuncDesc);
	}

	//member variables
	for(int i = 0; i != pTypeAttr->cVars; ++i){
		VARDESC* pVarDesc;
		hr = pTinfo->GetVarDesc(i, &pVarDesc); COMRet(hr);
		for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT("    ");
		std::wcout<<TEXT("Var memid = ")<<pVarDesc->memid<<TEXT("Varkind = ")<<pVarDesc->varkind<<std::endl;
		TCHAR szBuffer[30];
		wParamFlagsTranslate(pVarDesc->elemdescVar.paramdesc.wParamFlags, szBuffer, 30);
		for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT("    ");
		std::wcout<<"  Variable wParamFlags: "<<szBuffer<<std::endl;
		TExpandPointer(pVarDesc->elemdescVar.tdesc, 1);
		pTinfo->ReleaseVarDesc(pVarDesc);
	}
	pTinfo->ReleaseTypeAttr(pTypeAttr);
	return hr;
}
开发者ID:fumin,项目名称:NtuWebmailIEPlugin,代码行数:56,代码来源:top.cpp

示例7: _tmain

int _tmain(int argc, _TCHAR* argv[]){
	const OLECHAR szFile[] = TEXT("testmidl.tlb");//TEXT("D:\\Desktop\\COM_Type_Library_Viewer\\COM_Type_Library_Viewer\\testmidl.tlb");
	ITypeLib* p_tlib;  
	ITypeInfo* pTinfo;
	HRESULT hr = LoadTypeLib(szFile, &p_tlib); 
	//hr = p_tlib->GetTypeInfoOfGuid(IID_ISum, &pTinfo);//Succeeded
	//hr = p_tlib->GetTypeInfoOfGuid(LIBID_Component, &pTinfo);
	hr = p_tlib->GetTypeInfoOfGuid(CLSID_InsideCOM, &pTinfo);//Succeeded!!
	hr = PrintTInfo(pTinfo, 0);
	pTinfo->Release();
	p_tlib->Release();
	std::getchar();
	return 1;
}
开发者ID:fumin,项目名称:NtuWebmailIEPlugin,代码行数:14,代码来源:top.cpp

示例8: Invoke

STDMETHODIMP CJServer::Invoke(DISPID dispID, REFIID riid
    , LCID lcid, unsigned short wFlags, DISPPARAMS *pDispParams
    , VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
    HRESULT     hr;
    ITypeInfo  *pTI;
    LANGID      langID=PRIMARYLANGID(lcid);

    if (IID_NULL!=riid) return DISP_E_UNKNOWNINTERFACE;
    hr=GetTypeInfo(0, lcid, &pTI);
    if (FAILED(hr)) return hr;

    //This is exactly what DispInvoke does--so skip the overhead.
    hr=pTI->Invoke((SERVERCLASS *)this, dispID, wFlags
        , pDispParams, pVarResult, pExcepInfo, puArgErr);

    //Exception handling is done within ITypeInfo::Invoke
    pTI->Release();
    return hr;
}
开发者ID:EdKeith,项目名称:core,代码行数:20,代码来源:jdllcomx.cpp

示例9: get_coclassname

static void get_coclassname( IUnknown *punk, VARIANT *vres )
{
	HRESULT hr;
	IProvideClassInfo *pPCI;
	ITypeInfo *pTI;
	BSTR bstr = NULL;
	hr = punk->QueryInterface( IID_IProvideClassInfo, (void **)&pPCI );
	if ( SUCCEEDED(hr) && pPCI != NULL ) {
		hr = pPCI->GetClassInfo( &pTI );
		if ( SUCCEEDED(hr) && pTI != NULL ) {
			hr = pTI->GetDocumentation( MEMBERID_NIL, &bstr, NULL, NULL, NULL );
			pTI->Release();
		}
		pPCI->Release();
	}
	if ( bstr == NULL ) {
		bstr = SysAllocString( L"" );
	}
	vres->bstrVal = bstr;
	vres->vt = VT_BSTR;
}
开发者ID:zakki,项目名称:openhsp,代码行数:21,代码来源:hspvar_comobj.cpp

示例10: get_interfacename

static void get_interfacename( IUnknown *punk, VARIANT *vres )
{
	HRESULT hr;
	IDispatch *pDisp;
	ITypeInfo *pTI;
	BSTR bstr = NULL;
	hr = punk->QueryInterface( IID_IDispatch, (void **)&pDisp );
	if ( SUCCEEDED(hr) && pDisp != NULL ) {
		hr = pDisp->GetTypeInfo( 0, LOCALE_USER_DEFAULT, &pTI );
		if ( SUCCEEDED(hr) && pTI != NULL ) {
			hr = pTI->GetDocumentation( MEMBERID_NIL, &bstr, NULL, NULL, NULL );
			pTI->Release();
		}
		pDisp->Release();
	}
	if ( bstr == NULL ) {
		bstr = SysAllocString( L"" );
	}
	vres->bstrVal = bstr;
	vres->vt = VT_BSTR;
}
开发者ID:zakki,项目名称:openhsp,代码行数:21,代码来源:hspvar_comobj.cpp

示例11: GetUserDefaultLCID

CJSProxyObj::CJSProxyObj(CJSExtender* _pJSExtender, IDispatch *pDisp, const GUID iid, CString strPrefix) :
m_dwCookie(0xFEFEFEFE), m_pDisp(pDisp), m_EventIID(iid)
{
	m_pEventObj = nullptr;
	ITypeInfo* pTypeInfo = nullptr;
	m_pJSExtender = _pJSExtender;
	if (theApp.m_pEventProxy)
	{
		m_pEventObj = theApp.m_pEventProxy;
		theApp.m_pEventProxy = nullptr;
	}
	else
	{
		pDisp->GetTypeInfo(0, GetUserDefaultLCID(), &pTypeInfo);
		if (pTypeInfo)
		{
			CComPtr<ITypeLib> pTypeLib;
			UINT nIndex = 0;
			pTypeInfo->GetContainingTypeLib(&pTypeLib, &nIndex);
			pTypeLib->GetTypeInfoOfGuid(iid, &m_pTypeInfo);
			pTypeInfo->Release();
		}
	}

	CString strName = strPrefix;
	auto it = m_pJSExtender->m_mapCloudJSObject.find(strName);
	if (it != m_pJSExtender->m_mapCloudJSObject.end())
	{
		int nSize = m_pJSExtender->m_mapCloudJSObject.size();
		CString s = _T("");
		s.Format(_T("%s_%d_"), strName, nSize);
		strName = s;
	}
	m_bstrPrefix = CComBSTR(strName);
	SetEventNames();
	m_pJSExtender->m_mapCloudJSObject[strName] = this;

	HRESULT hr = AtlAdvise(m_pDisp, this, m_EventIID, &m_dwCookie);
}
开发者ID:SmallMrKong,项目名称:TANGRAM,代码行数:39,代码来源:JSExtender.cpp

示例12: _AfxUnregisterInterfaces

void _AfxUnregisterInterfaces(ITypeLib* pTypeLib)
{
	TCHAR szKey[128];
	lstrcpy(szKey, _T("Interface\\"));
	LPTSTR pszGuid = szKey + lstrlen(szKey);

	int cTypeInfo = pTypeLib->GetTypeInfoCount();

	for (int i = 0; i < cTypeInfo; i++)
	{
		TYPEKIND tk;
		if (SUCCEEDED(pTypeLib->GetTypeInfoType(i, &tk)) &&
			(tk == TKIND_DISPATCH || tk == TKIND_INTERFACE))
		{
			ITypeInfo* pTypeInfo = NULL;
			if (SUCCEEDED(pTypeLib->GetTypeInfo(i, &pTypeInfo)))
			{
				TYPEATTR* pTypeAttr;
				if (SUCCEEDED(pTypeInfo->GetTypeAttr(&pTypeAttr)))
				{
#if defined(_UNICODE) || defined(OLE2ANSI)
					StringFromGUID2(pTypeAttr->guid, pszGuid, GUID_CCH);
#else
					WCHAR wszGuid[39];
					StringFromGUID2(pTypeAttr->guid, wszGuid, GUID_CCH);
					_wcstombsz(pszGuid, wszGuid, GUID_CCH);
#endif
					_AfxRecursiveRegDeleteKey(HKEY_CLASSES_ROOT, szKey);
					pTypeInfo->ReleaseTypeAttr(pTypeAttr);
				}

				pTypeInfo->Release();
			}
		}
	}
}
开发者ID:Rupan,项目名称:winscp,代码行数:36,代码来源:ctlreg.cpp

示例13:

ITypeInfo *tCOMUtil::GetDefaultInterfaceTypeInfo(ITypeInfo* pCoClassinfo,
                                                 bool source)
           
{
  ITypeInfo* typeinfo = NULL;  //Use this to determine success
  TYPEATTR* pTA = NULL;
  HRESULT hr = S_OK;

  if (SUCCEEDED(pCoClassinfo->GetTypeAttr(&pTA)))
  {
    UINT i = 0;
    int iFlags = 0;

    for (i=0; i < pTA->cImplTypes; i++)
    {
      //Get the implementation type for this interface
      hr = pCoClassinfo->GetImplTypeFlags(i, &iFlags);

      if (FAILED(hr))
        continue;

      if (iFlags & IMPLTYPEFLAG_FDEFAULT || pTA->cImplTypes == 1)
      {
        if(source == false && !(iFlags & IMPLTYPEFLAG_FSOURCE)
        || source == true && (iFlags & IMPLTYPEFLAG_FSOURCE))
        {
          HREFTYPE    hRefType=NULL;

          /*
           * This is the interface we want.  Get a handle to
           * the type description from which we can then get
           * the ITypeInfo.
           */
          pCoClassinfo->GetRefTypeOfImplType(i, &hRefType);
          hr = pCoClassinfo->GetRefTypeInfo(hRefType, &typeinfo);

          // gets typeattr info
          TYPEATTR *ptypeattr = NULL;
          GUID guid;
          TYPEKIND typekind;

          hr = typeinfo->GetTypeAttr(&ptypeattr);

          if(FAILED(hr))
          {
            typeinfo->Release();
            typeinfo = NULL;
            break;
          }

          guid = ptypeattr->guid;
          typekind = ptypeattr->typekind;

          typeinfo->ReleaseTypeAttr(ptypeattr);

          if(typekind == TKIND_DISPATCH)
          {
            // found!
            break;
          }
        }
      }
    }

    pCoClassinfo->ReleaseTypeAttr(pTA);
  }

  return typeinfo;
}
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:69,代码来源:tCOMUtil.cpp

示例14: GetDispatch

IDispatch* CItemHolder::GetDispatch(IActiveScriptSite* pSite, LPOLESTR pstrName, bool fSameApt)
{
	IDispatchEx* pDispEx = m_pDispEx;
	IDispatch* pDisp = m_pDisp;
	ATLTRACE(_("CItemHolder::GetDispatch in Thread:%08X name=%ls sameptr=%d\n"), GetCurrentThreadId(), pstrName, fSameApt);
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
	if (fSameApt)
	{
#endif
		if (pDisp == NULL && pDispEx == NULL)
		{
			ATLTRACE(_("CItemHolder::GetDispatch in Thread:%08X\n"), GetCurrentThreadId());
			IUnknown* pUnk = NULL;
			ITypeInfo* pTypeInfo = NULL;
			HRESULT hr = pSite->GetItemInfo(pstrName, SCRIPTINFO_IUNKNOWN, &pUnk, &pTypeInfo);
			if (hr == S_OK)
			{
				if (pTypeInfo) pTypeInfo->Release();
				if (pUnk->QueryInterface(IID_IDispatchEx, (void**)&pDispEx) == S_OK)
				{
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
					HRESULT hr = m_pGIPDispEx.Globalize(pDispEx);
					ATLTRACE(_T("Globalize Item = %08X\n"), hr);
#endif
					m_pDispEx = pDispEx;
				}
				else
				{
					pDispEx = NULL;
					if (pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp) == S_OK)
					{
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
						HRESULT hr = m_pGIPDisp.Globalize(pDisp);
						ATLTRACE(_T("Globalize Item = %08X\n"), hr);
#endif
						m_pDisp = pDisp;
					}
				}
				pUnk->Release();
			}
		}

		if (pDispEx)
		{
			pDispEx->AddRef();
		}
		else if (pDisp)
		{
			pDisp->AddRef();
		}
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
	}
	else
	{
		if (m_pGIPDisp.IsOK() == false && m_pGIPDispEx.IsOK() == false)
		{
			ATLTRACE(_("CItemHolder::GetDispatch in Thread:%08X\n"), GetCurrentThreadId());
			IUnknown* pUnk = NULL;
			ITypeInfo* pTypeInfo = NULL;
			HRESULT hr = pSite->GetItemInfo(pstrName, SCRIPTINFO_IUNKNOWN, &pUnk, &pTypeInfo);
			if (hr == S_OK)
			{
				if (pTypeInfo) pTypeInfo->Release();
				if (pUnk->QueryInterface(IID_IDispatchEx, (void**)&pDispEx) != S_OK)
				{
					pDispEx = NULL;
					if (pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp) != S_OK)
					{
						pDisp = NULL;
					}
				}
				pUnk->Release();
			}
		}
		if (m_pGIPDispEx.IsOK())
		{
			IDispatchEx* p;
			HRESULT hr = m_pGIPDispEx.Localize(&p);
			ATLTRACE(_("Localize DispEx = %08X\n"), hr);
			return p;
		}
		if (m_pGIPDisp.IsOK())
		{
			IDispatch* p;
			HRESULT hr = m_pGIPDisp.Localize(&p);
			ATLTRACE(_("Localize Disp = %08X\n"), hr);
			return p;
		}
	}
#endif
	return (pDispEx) ? pDispEx : pDisp;
}
开发者ID:arton,项目名称:RScript19,代码行数:92,代码来源:itemdisp.cpp

示例15: InitEvent

STDMETHODIMP ESource::InitEvent(IDispatch *SourceDispatch,
                 OrxScript *ORexxScript,
                 FILE *LogFile)
{
    ITypeInfo *SourceType;
    TYPEATTR  *TypeAttributes;
    BSTR       SourceName;
    unsigned int NameCount;
    int        i;
    FUNCDESC  *FuncDesc;
    char       DispIDName[29];
    PEMAP      NewMap;
    HRESULT    RetCode=S_OK;
    int        EMCount;

    FPRINTF2(LogFile,"created a new Event Source. %p\n",this);
    FPRINTF2(DLLlogfile,"created a new Event Source.%p\n",this);
    EventType = AddScriptlet;
    Source = SourceDispatch;   // Mimick the ParseProcedures "THIS" parameter by returning this pointer.
    Engine = ORexxScript;
    Connected = false;
    ConnectionPoint = NULL;
    Container = NULL;
    logfile = LogFile;

    RetCode = GetTypeInfo(&SourceType);
    if (SUCCEEDED(RetCode))
    {
        RetCode = SourceType->GetTypeAttr(&TypeAttributes);
        memcpy(&SourceGUID,&TypeAttributes->guid,sizeof(GUID));
        EMCount = TypeAttributes->cFuncs;
        SourceType->ReleaseTypeAttr(TypeAttributes);
        OLECHAR    lGUID[50];
        StringFromGUID2(SourceGUID,lGUID,sizeof(lGUID));
        FPRINTF2(logfile,"The GUID is %S and there are %d functions.\n",lGUID,EMCount);

        /*    For each entry in the type library, create an entry on the Event Map chain.
         *  This is a many to one relation.  Each of the different Source Disp ID's
         *  will translate to the same Sink Disp ID.  There is only one chunk of code
         *  being bound to this Event that the Type Library is describing.  So every
         *  Source call must map to the same Sink.
         */
        for (i=0; i<EMCount; i++)
        {
            SourceType->GetFuncDesc(i, &FuncDesc);
            //  Despite what the documentation says, this returns Max Names, not Max Names - 1.
            // The first name is the function name, the remainder if they exist are parameters.
            SourceType->GetNames(FuncDesc->memid, &SourceName, 1, &NameCount);
            sprintf(DispIDName,"%d",FuncDesc->memid);
            //  This creates the entry for the function with an invalid DispID to call.
            RetCode = AddMap(DispIDName,&NewMap);
            if (FAILED(RetCode)) return RetCode;
            FPRINTF2(logfile,"ESource::InitEvent - AddScriptlet \"%S\" \n",SourceName);
            NewMap->SourceEventName = SourceName;
            SourceType->ReleaseFuncDesc(FuncDesc);
        }

        SourceType->Release();
    }
    else
    {
        FPRINTF2(logfile,"Could not obtain TypInfo for this event! HRESULT %08x\n",RetCode);
    }
    return RetCode;
}
开发者ID:KlemensEngel,项目名称:oorexxforandroid,代码行数:65,代码来源:orxevents.cpp


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