本文整理汇总了C++中ITypeInfo::GetVarDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ ITypeInfo::GetVarDesc方法的具体用法?C++ ITypeInfo::GetVarDesc怎么用?C++ ITypeInfo::GetVarDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeInfo
的用法示例。
在下文中一共展示了ITypeInfo::GetVarDesc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyCom_BuildPyException
PyObject *PyITypeInfo::GetVarDesc(int index)
{
VARDESC *desc;
ITypeInfo *pMyTypeInfo = GetI(this);
if (pMyTypeInfo==NULL) return NULL;
PY_INTERFACE_PRECALL;
SCODE sc = pMyTypeInfo->GetVarDesc(index, &desc);
PY_INTERFACE_POSTCALL;
if (FAILED(sc))
return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo);
PyObject *ret = PyObject_FromVARDESC(desc);
{
PY_INTERFACE_PRECALL;
pMyTypeInfo->ReleaseVarDesc(desc);
PY_INTERFACE_POSTCALL;
}
return ret;
}
示例2: ThrowComFail
JNIEXPORT jobject JNICALL Java_org_racob_com_TypeInfo_getVarDesc
(JNIEnv *env, jobject obj, jint pointer, jint index)
{
ITypeInfo *typeInfo = (ITypeInfo *) pointer;
VARDESC *varDesc = NULL;
HRESULT hr = typeInfo->GetVarDesc(index, &varDesc);
if (!SUCCEEDED(hr)) {
ThrowComFail(env, "getVarDesc failed", hr);
return NULL;
}
// We have a constant so let's save the variant
jobject cValue = varDesc->varkind == VAR_CONST ? createVariant(env, varDesc->lpvarValue) : NULL;
jclass autoClass = env->FindClass("org/racob/com/VarDesc");
jmethodID autoCons = env->GetMethodID(autoClass, "<init>", "(ILorg/racob/com/Variant;II)V");
jobject newAuto = env->NewObject(autoClass, autoCons, varDesc->memid,
cValue, varDesc->varkind, varDesc->wVarFlags);
typeInfo->ReleaseVarDesc(varDesc);
return newAuto;
}
示例3: 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();
}
示例4: 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;
}