PyObject *PyITypeInfo::GetRefTypeOfImplType(int index) { HREFTYPE href; ITypeInfo *pMyTypeInfo = GetI(this); if (pMyTypeInfo==NULL) return NULL; PY_INTERFACE_PRECALL; SCODE sc = pMyTypeInfo->GetRefTypeOfImplType(index, &href); PY_INTERFACE_POSTCALL; if (FAILED(sc)) return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo); return Py_BuildValue("i", href); }
JNIEXPORT jint JNICALL Java_org_racob_com_TypeInfo_getRefTypeOfImplType (JNIEnv *env, jobject obj, jint pointer, jint index) { ITypeInfo *typeInfo = (ITypeInfo *) pointer; HREFTYPE href; HRESULT hr = typeInfo->GetRefTypeOfImplType(index, &href); if (!SUCCEEDED(hr)) { ThrowComFail(env, "getRefTypeOfImplType failed", hr); return NULL; } return (jint) href; }
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; }