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


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

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


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

示例1: SetEventNames

HRESULT CJSProxyObj::SetEventNames()
{
	ITypeInfo* pInfo;
	if (m_pTypeInfo == nullptr)
		pInfo = theApp.m_pEventTypeInfo.p;
	else
		pInfo = m_pTypeInfo.p;
	TYPEATTR *pta = nullptr;;
	HRESULT hr = pInfo->GetTypeAttr(&pta);
	if (FAILED(hr))
		return hr;
	BSTR bstrName = ::SysAllocString(L"");
	FUNCDESC *pfd = nullptr;
	unsigned int uiNames = 0;
	for (int i = 0; i < pta->cFuncs; i++)
	{
		hr = pInfo->GetFuncDesc(i, &pfd);
		if (FAILED(hr))
			continue;

		hr = pInfo->GetNames(pfd->memid, &bstrName, 1, &uiNames);
		if (SUCCEEDED(hr) && bstrName && SysStringLen(bstrName))
		{
			m_mapDispId.Add(pfd->memid, bstrName);
			ATLTRACE(_T("*********Add function '%s' in Tangram*******\r\n"), OLE2T(bstrName));
		}
		pInfo->ReleaseFuncDesc(pfd);
		pfd = nullptr;
	}
	pInfo->ReleaseTypeAttr(pta);
	return hr;
}
开发者ID:SmallMrKong,项目名称:TANGRAM,代码行数:32,代码来源:JSExtender.cpp

示例2: copyNameGUID

/* Extract GUID with name nameGUID and assign it to guid */
static void
InitTypeLibGUID(
    ITypeLib* const pTypeLib, ITypeInfo** const typeInfoPtrArray,
    MEMBERID* const memberIdArray, const nsAString& nameGUID,
    const TYPEKIND typeKindGUID, GUID& guid) {
    
    // Copy nameGUID as FindName requires a non const string
    nsString copyNameGUID(nameGUID);
    PRInt32 hashValue = 0;
    PRUint16 countFound = 1;
    HRESULT result = pTypeLib->FindName(
        copyNameGUID.BeginWriting(), hashValue, typeInfoPtrArray, 
        memberIdArray, &countFound
    );
    
    if (result == S_OK) {
        for (PRUint16 i = 0; i < countFound; ++i) {
            ITypeInfo* pTypeInfo = typeInfoPtrArray[i];
            typeInfoPtrArray[i] = 0;
            TYPEATTR* pTypeAttribute = 0;
            
            result = pTypeInfo->GetTypeAttr(&pTypeAttribute);
            if (result == S_OK) {
                if (pTypeAttribute->typekind == typeKindGUID) {
                    guid = pTypeAttribute->guid;
                }
                pTypeInfo->ReleaseTypeAttr(pTypeAttribute);
            }
        
            SAFE_RELEASE(pTypeInfo);
        }
    }
}
开发者ID:1981khj,项目名称:rainbow,代码行数:34,代码来源:VideoSourceWin.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: PyCom_BuildPyException

PyObject *PyITypeInfo::GetTypeAttr()
{
	TYPEATTR *attr;
	ITypeInfo *pMyTypeInfo = GetI(this);
	if (pMyTypeInfo==NULL) return NULL;
	PY_INTERFACE_PRECALL;
	SCODE sc = pMyTypeInfo->GetTypeAttr(&attr);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo);

/*	
	PyObject *obIID = PyWinObject_FromIID(attr->guid);
	PyObject *obDescAlias;
	// Some (only a few 16 bit MSOffice only one so far, and even then only occasionally!)
	// servers seem to send invalid tdescAlias when its not actually an alias.
	if (attr->typekind == TKIND_ALIAS)
		obDescAlias = MakeTypeDesc(&attr->tdescAlias);
	else {
		Py_INCREF(Py_None);
		obDescAlias=Py_None;
	}

	PyObject *obIDLDesc = MakeIDLDesc(&attr->idldescType);
	PyObject *ret = Py_BuildValue("(OiiiiiiiiiiiiiOO)",
		obIID,                   // @tupleitem 0|<o PyIID>|IID|The IID
		attr->lcid,				 // @tupleitem 1|int|lcid|The lcid
		attr->memidConstructor,	 // @tupleitem 2|int|memidConstructor|ID of constructor
		attr->memidDestructor,	 // @tupleitem 3|int|memidDestructor|ID of destructor,
		attr->cbSizeInstance,	 // @tupleitem 4|int|cbSizeInstance|The size of an instance of this type
		attr->typekind,			 // @tupleitem 5|int|typekind|The kind of type this information describes.  One of the win32con.TKIND_* constants.
		attr->cFuncs,			 // @tupleitem 6|int|cFuncs|Number of functions.
		attr->cVars,			 // @tupleitem 7|int|cVars|Number of variables/data members.
		attr->cImplTypes,		 // @tupleitem 8|int|cImplTypes|Number of implemented interfaces.
		attr->cbSizeVft,		 // @tupleitem 9|int|cbSizeVft|The size of this type's VTBL
		attr->cbAlignment,		 // @tupleitem 10|int|cbAlignment|Byte alignment for an instance of this type.
		attr->wTypeFlags,		 // @tupleitem 11|int|wTypeFlags|One of the pythoncom TYPEFLAG_
		attr->wMajorVerNum,		 // @tupleitem 12|int|wMajorVerNum|Major version number.
		attr->wMinorVerNum,		 // @tupleitem 13|int|wMinorVerNum|Minor version number.
		obDescAlias,			 // @tupleitem 14|<o TYPEDESC>|obDescAlias|If TypeKind == pythoncom.TKIND_ALIAS, specifies the type for which this type is an alias.
		obIDLDesc				 // @tupleitem 15|<o IDLDESC>|obIDLDesc|IDL attributes of the described type.
	);
	Py_XDECREF(obDescAlias);
	Py_XDECREF(obIDLDesc);
	Py_XDECREF(obIID);
***/
	PyObject *ret = PyObject_FromTYPEATTR(attr);

	{
	PY_INTERFACE_PRECALL;
	pMyTypeInfo->ReleaseTypeAttr(attr);
	PY_INTERFACE_POSTCALL;
	}

	return ret;
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:56,代码来源:PyIType.cpp

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

示例6: FindCLSID

CLSID tCOMUtil::FindCLSID(ITypeInfo* interface_typeinfo)
{
  ITypeLib* ptypelib    = NULL;
  ITypeInfo* ptypeinfo  = NULL;
  long count            = 0;
  IID iid               = IID_NULL;
  TYPEATTR* ptypeattr   = NULL;
  TYPEKIND tkind;
  bool found            = false;
  CLSID clsid           = IID_NULL;

  // gets IID
  interface_typeinfo->GetTypeAttr(&ptypeattr);

  iid = ptypeattr->guid;
  interface_typeinfo->ReleaseTypeAttr(ptypeattr);
  ptypeattr = NULL;

  // Gets type library
  interface_typeinfo->GetContainingTypeLib(&ptypelib, NULL);

  // iterates looking for IID inside some coclass
  count = ptypelib->GetTypeInfoCount();

  while(count-- && !found)
  {
    ptypelib->GetTypeInfoType(count, &tkind);

    if(tkind != TKIND_COCLASS)
      continue;

    // look inside
    ptypelib->GetTypeInfo(count, &ptypeinfo);

    // gets counts and clsid
    ptypeinfo->GetTypeAttr(&ptypeattr);
    long ifaces_count   = ptypeattr->cImplTypes;
    clsid = ptypeattr->guid;

    ptypeinfo->ReleaseTypeAttr(ptypeattr);
    ptypeattr = NULL;

    TYPEFLAGS typeflags;
    HREFTYPE RefType;
    ITypeInfo* piface_typeinfo = NULL;

    while(ifaces_count-- && !found)
    {
      ptypeinfo->GetRefTypeOfImplType(ifaces_count, &RefType);
      ptypeinfo->GetRefTypeInfo(RefType, &piface_typeinfo);
      piface_typeinfo->GetTypeAttr(&ptypeattr);

      if(IsEqualIID(ptypeattr->guid, iid))
      {
        found = true;
      }

      piface_typeinfo->ReleaseTypeAttr(ptypeattr);
      ptypeattr = NULL;

      COM_RELEASE(piface_typeinfo);
    }

    COM_RELEASE(ptypeinfo);
  }

  COM_RELEASE(ptypelib);

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

示例7:

ITypeInfo *tCOMUtil::GetDispatchTypeInfo(IDispatch* pdisp)
{
  ITypeInfo* typeinfo = NULL;

  HRESULT hr = pdisp->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &typeinfo);

  if(FAILED(hr))
    return NULL;

  TYPEATTR *ptypeattr = NULL;

  typeinfo->GetTypeAttr(&ptypeattr);

  TYPEKIND typekind = ptypeattr->typekind;

  if(typekind == TKIND_DISPATCH)
  {
    typeinfo->ReleaseTypeAttr(ptypeattr);
    return typeinfo;
  }

  // tries to find another description of the same
  // interface in the typelib with TKIND_DISPATCH

  ITypeLib *ptypelib = NULL;
  unsigned int dumb = 0;
  IID iid = ptypeattr->guid;

  hr = typeinfo->GetContainingTypeLib(&ptypelib, &dumb);

  typeinfo->ReleaseTypeAttr(ptypeattr);

  // if there's no containing type lib, we have to
  // trust this one is the right type info
  if(FAILED(hr))
    return typeinfo;

  // obtem a typeinfo do iid fornecido
  // caso haja uma implementacao dispinterface,
  // esta' e' que sera' retornada (segundo
  // documentacao do ActiveX

  ITypeInfo* typeinfo_guid = NULL;

  hr = ptypelib->GetTypeInfoOfGuid(iid, &typeinfo_guid);

  if(FAILED(hr))
  {
    ptypelib->Release();
    return typeinfo;
  }

  // verifica se e' dispinterface
  TYPEATTR *ptypeattr_iface = NULL;

  hr = typeinfo_guid->GetTypeAttr(&ptypeattr_iface);
  TYPEKIND typekind_iface = ptypeattr_iface->typekind;
  typeinfo_guid->ReleaseTypeAttr(ptypeattr_iface);

  if(typekind_iface == TKIND_DISPATCH)
  {
    // releases original type information
    COM_RELEASE(typeinfo);

    return typeinfo_guid;
  }
  else
  {
    COM_RELEASE(typeinfo_guid);
    
    // returns original type info
    return typeinfo;
  }
}
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:74,代码来源:tCOMUtil.cpp

示例8: ASSERT

BOOL CTreeItem::ExpandTypeInfo( HTREEITEM hitem )
{
	ASSERT(m_pTree) ;
	ASSERT(hitem) ;

	CTreeItem*  pNewItem = NULL ;
	HRESULT         hr = S_OK ;
	TV_INSERTSTRUCT tvis ;
	CString         strError = "Enumerating TypeInfo" ;
	TYPEATTR*       pattr = NULL ;
	ITypeInfo*      pti = GetTypeInfo() ;
	ASSERT(pti) ;
	BOOL            fExpand = FALSE ;

	tvis.hParent = hitem  ;
	tvis.hInsertAfter = TVI_LAST ;
	tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN ;
	tvis.item.iImage = typeUnknown ;
	tvis.item.iSelectedImage = tvis.item.iImage + 1 ;

	TRY
	{
		ENSURE(pti);
		hr = pti->GetTypeAttr(&pattr) ;
		if FAILED(hr)
		{
			strError.Format(_T("ITypeInfo::GetTypeAttr() failed"), hr ) ;
			AfxThrowMemoryException() ;
		}

		switch(pattr->typekind)
		{
		// typedef [attributes] enum [tag] {
		//      enumlist
		// } enumname;
		//
		// "typedef enum enumname"
		case TKIND_ENUM:
			fExpand = ExpandVars( hitem ) ;
		break ;

		// typedef [attributes]
		//  struct [tag] {
		//      memberlist
		//  } structname;
		//
		// "typedef struct structname"
		case TKIND_RECORD:
			fExpand = ExpandVars( hitem ) ;
		break ;

		// [attributes]
		//  module modulename {
		//      elementlist
		// };
		case TKIND_MODULE:
			if (pattr->cVars)
			{
				// Add "Constants" folder
				//
				#pragma warning (suppress: 6211)
				#pragma warning (suppress: 6014)
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeProperties ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cVars ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Constants") ;
				tvis.item.iImage = typeConstants ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
			if (pattr->cFuncs)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeMethods ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cFuncs ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Functions") ;
				tvis.item.iImage = typeMethods ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
		break ;

		// [attributes]
		//  interface interfacename  [:baseinterface] {
		//      functionlist
		// };
		case TKIND_INTERFACE:
			fExpand = ExpandFuncs( hitem) ;
			if (pattr->cImplTypes)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeImplTypes ;
//.........这里部分代码省略.........
开发者ID:jetlive,项目名称:skiaming,代码行数:101,代码来源:tree.cpp

示例9: DumpComTypes

void DumpComTypes(ITypeLib* pTypeLib)
{
	// Dump out the types.
	USES_CONVERSION;
	pTypeLib->AddRef();
	ULONG typeCount = pTypeLib->GetTypeInfoCount();
	cout << "\n****** The COM Types ******" << endl;
	cout << "There are " << typeCount << " in this type lib" << endl << endl;

	for(ULONG typeIndex = 0; typeIndex < typeCount; typeIndex++)
	{
		ITypeInfo* pInfo = NULL;
		TYPEATTR* typeAtt;
		CComBSTR temp;
		ULONG index = 0;
		ULONG numbMembers = 0;

		pTypeLib->GetTypeInfo(typeIndex, &pInfo);
		pInfo->GetTypeAttr(&typeAtt);		

		// Based on the kind of COM type, print out some information. 
		switch(typeAtt->typekind)
		{
		case TKIND_COCLASS:  // type is a coclass.
			cout << "(" << typeIndex << ")" << " Coclass with " << typeAtt->cImplTypes << " interface(s). ******" << endl;
			temp = typeAtt->guid;
			cout << "->CLSID: " << W2A(temp.Copy()) << endl;
			pInfo->GetDocumentation(-1, &temp, NULL, NULL, NULL);
			cout << "->Name: " << W2A(temp.Copy()) << endl;
		break;

		case TKIND_DISPATCH:  // type is a IDispatch derived interface.
			cout << "(" << typeIndex << ")" << " IDispatch based interface with " << typeAtt->cFuncs << " method(s). ******" << endl;
			temp = typeAtt->guid;
			cout << "->IID: " << W2A(temp.Copy()) << endl;	
			pInfo->GetDocumentation(-1, &temp, NULL, NULL, NULL);
			cout << "->Name: " << W2A(temp.Copy()) << endl;
			
			numbMembers = typeAtt->cFuncs;
			for(index = 0; index < numbMembers; index++)
			{
				FUNCDESC* fx;
				pInfo->GetFuncDesc(index, &fx);
				pInfo->GetDocumentation(fx->memid, &temp, NULL, NULL, NULL);
				cout << "  ->" << W2A(temp.Copy()) << " has " << fx->cParams << " params" << endl;
				pInfo->ReleaseFuncDesc(fx);
			}			
		break;

		case TKIND_INTERFACE: // Type is an IUnknown derived interface.
			cout << "(" << typeIndex << ")" << " IUnknown based interface with " << typeAtt->cFuncs << " method(s). ******" << endl;
			temp = typeAtt->guid;
			cout << "->IID: " << W2A(temp.Copy()) << endl;			
			pInfo->GetDocumentation(-1, &temp, NULL, NULL, NULL);
			cout << "->Name: " << W2A(temp.Copy()) << endl;
			
			numbMembers = typeAtt->cFuncs;
			for(index = 0; index < numbMembers; index++)
			{
				FUNCDESC* fx;
				pInfo->GetFuncDesc(index, &fx);
				pInfo->GetDocumentation(fx->memid, &temp, NULL, NULL, NULL);
				cout << "  ->" << W2A(temp.Copy()) << " has " << fx->cParams << " param(s)" << endl;
				pInfo->ReleaseFuncDesc(fx);
			}			
		break;

		case TKIND_ENUM:  // Type is an enum.
			cout << "(" << typeIndex << ")" << " Enum with " << typeAtt->cVars << " member(s). ******" << endl;
			pInfo->GetDocumentation(-1, &temp, NULL, NULL, NULL);
			cout << "->Name: " << W2A(temp.Copy()) << endl;
			
			numbMembers = typeAtt->cVars;
			for(index = 0; index < numbMembers; index++)
			{
				VARDESC* var;
				pInfo->GetVarDesc(index, &var);
				pInfo->GetDocumentation(var->memid, &temp, NULL, NULL, NULL);				 
				cout << "  ->" << W2A(temp.Copy()) << endl;
				pInfo->ReleaseVarDesc(var);
			}
		break;
		
		default:
			cout << "Some other type I don't care about..." << endl;

		}
		cout << endl;
		pInfo->ReleaseTypeAttr(typeAtt);
		pInfo->Release();
	}
	pTypeLib->Release();
}
开发者ID:rojac07,项目名称:COM,代码行数:93,代码来源:CppComTypeReader.cpp

示例10:

ITypeInfo *tCOMUtil::GetDefaultInterfaceTypeInfo(ITypeInfo* pCoClassinfo,
                                                 bool source)
           
{
  ITypeInfo* typeinfo = NULL;

  // if the component does not have a dispinterface typeinfo 
  // for events, we stay with an interface typeinfo
  ITypeInfo* interface_typeinfo = NULL;

  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=0;

          /*
           * 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))
          {
            COM_RELEASE(typeinfo);
            break;
          }

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

          typeinfo->ReleaseTypeAttr(ptypeattr);

          if(typekind == TKIND_DISPATCH)
          {
            // found!
            COM_RELEASE(interface_typeinfo);
            break;
          }
          else // hold this pointer. If we do not find
            // anything better, we stay with this typeinfo
          {
            COM_RELEASE(interface_typeinfo);
            interface_typeinfo = typeinfo;
            typeinfo = NULL;
          }
        }
      }
    }

    pCoClassinfo->ReleaseTypeAttr(pTA);
  }

  if(!typeinfo)
    return interface_typeinfo;
  else
    return typeinfo;
}
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:84,代码来源:tCOMUtil.cpp

示例11: rec

BOOL comauto::RecordInfo::IsMatchingType( IRecordInfo *pRecordInfo)
{
	BOOL rt = TRUE;
	ITypeInfo* otypeinfo = 0;
	ITypeInfo* rectypeinfo = 0;
	ITypeInfo* orectypeinfo = 0;
	TYPEATTR* otypeattr = 0;
	VARDESC* vd = 0;
	VARDESC* ovd = 0;
	BSTR varname = NULL;
	BSTR ovarname = NULL;
	try
	{
		WRAP( pRecordInfo->GetTypeInfo( &otypeinfo))
		WRAP( otypeinfo->GetTypeAttr( &otypeattr))
		if (m_typeattr->guid == otypeattr->guid) goto Cleanup;
		if (m_typeattr->cVars != otypeattr->cVars) {rt=FALSE; goto Cleanup;}
		unsigned short ii;
		for (ii = 0; ii < m_typeattr->cVars; ++ii)
		{
			if (vd)
			{
				m_typeinfo->ReleaseVarDesc( vd);
				vd = NULL;
			}
			WRAP( m_typeinfo->GetVarDesc( ii, &vd))
			if (ovd)
			{
				otypeinfo->ReleaseVarDesc( ovd);
				ovd = NULL;
			}
			WRAP( otypeinfo->GetVarDesc( ii, &ovd))

			if (vd->elemdescVar.tdesc.vt != ovd->elemdescVar.tdesc.vt || vd->oInst != ovd->oInst)
			{
				rt=FALSE; goto Cleanup;
			}
			UINT nn;
			if (varname)
			{
				::SysFreeString( varname); varname = NULL;
			}
			WRAP( m_typeinfo->GetNames( vd->memid, &varname, 1, &nn))
			if (ovarname)
			{
				::SysFreeString( ovarname); ovarname = NULL;
			}
			WRAP( otypeinfo->GetNames( ovd->memid, &ovarname, 1, &nn))

			if (wcscmp( varname, ovarname) != 0)
			{
				rt=FALSE; goto Cleanup;
			}

			if (vd->elemdescVar.tdesc.vt == VT_USERDEFINED)
			{
				if (rectypeinfo)
				{
					rectypeinfo->Release();
					rectypeinfo = 0;
				}
				WRAP( m_typeinfo->GetRefTypeInfo( vd->elemdescVar.tdesc.hreftype, &rectypeinfo))
				if (orectypeinfo)
				{
					orectypeinfo->Release();
					orectypeinfo = NULL;
				}
				WRAP( m_typeinfo->GetRefTypeInfo( ovd->elemdescVar.tdesc.hreftype, &orectypeinfo))

				comauto::RecordInfo rec( rectypeinfo);
				comauto::RecordInfo orec( orectypeinfo);
				if (rec.IsMatchingType( &orec) == FALSE)
				{
					rt=FALSE; goto Cleanup;
				}
			}
		}
	}
	catch (...)
	{
		rt = FALSE;
	}
Cleanup:
	if (vd) m_typeinfo->ReleaseVarDesc( vd);
	if (ovd) otypeinfo->ReleaseVarDesc( ovd);
	if (otypeattr) otypeinfo->ReleaseTypeAttr( otypeattr);
	if (rectypeinfo) rectypeinfo->Release();
	if (orectypeinfo) orectypeinfo->Release();
	if (otypeinfo) otypeinfo->Release();
	if (varname) ::SysFreeString( varname);
	if (ovarname) ::SysFreeString( ovarname);
	return rt;
}
开发者ID:ProjectTegano,项目名称:Tegano,代码行数:93,代码来源:recordinfo.cpp

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

示例13: GetUserDefinedType

//-----------------------------------------------------------------------------
// Name: GetUserDefinedType
// Object: try to get standard type from user defined type
// Parameters :
//     in  : HREFTYPE hrefType
//           ITypeInfo* pTypeInfo
//           VARTYPE* pType
//     out :
//     return : success result
//-----------------------------------------------------------------------------
HRESULT CParameterInfo::GetUserDefinedType(HREFTYPE hrefType, ITypeInfo* pTypeInfo,VARTYPE* pType)
{
    if (IsBadReadPtr(pTypeInfo,sizeof(ITypeInfo)))
        return E_FAIL;

    ITypeInfo* pUserDefinedTypeInfo;
    HRESULT hr = pTypeInfo->GetRefTypeInfo(hrefType, &pUserDefinedTypeInfo);
    if (SUCCEEDED(hr) && pUserDefinedTypeInfo)
    {
        TYPEATTR* pTypeAttr;
        hr = pUserDefinedTypeInfo->GetTypeAttr( &pTypeAttr );
        if( FAILED( hr ) )
            return hr;

        hr=S_OK;

        switch(pTypeAttr->typekind)
        {
        case TKIND_ENUM:
            *pType = VT_I4;
            break;
        case TKIND_RECORD:
            *pType = VT_RECORD;
            break;
        case TKIND_MODULE:
            break;
        case TKIND_INTERFACE:
            *pType = VT_UNKNOWN;
            break;
        case TKIND_DISPATCH:
            *pType = VT_DISPATCH;
            break;
        case TKIND_COCLASS:
            *pType = VT_DISPATCH;
            break;
        case TKIND_ALIAS:
            switch (pTypeAttr->tdescAlias.vt)
            {
            default:
                break;
            case VT_I2:
            case VT_I4:
            case VT_R4:
            case VT_R8:
            case VT_I1:
            case VT_UI1:
            case VT_UI2:
            case VT_UI4:
            case VT_I8:
            case VT_UI8:
            case VT_INT:
            case VT_UINT:
                *pType = pTypeAttr->tdescAlias.vt;
                // we should have pTypeAttr->tdescAlias.hreftype == 0
                break;
            case VT_USERDEFINED:
                hr=this->GetUserDefinedType(pTypeAttr->tdescAlias.hreftype, pUserDefinedTypeInfo,pType);
            }
            break;
        case TKIND_UNION:
            break;
        case TKIND_MAX:
            break;
        default:
            break;
        }

        CSecureIUnknown::Release(pUserDefinedTypeInfo);
        return hr;
    }
    return E_FAIL;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:82,代码来源:ParameterInfo.cpp


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