本文整理汇总了C#中System.Runtime.InteropServices.ComTypes.GetRefTypeOfImplType方法的典型用法代码示例。如果您正苦于以下问题:C# ComTypes.GetRefTypeOfImplType方法的具体用法?C# ComTypes.GetRefTypeOfImplType怎么用?C# ComTypes.GetRefTypeOfImplType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.InteropServices.ComTypes
的用法示例。
在下文中一共展示了ComTypes.GetRefTypeOfImplType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDispatchTypeInfoFromCoClassTypeInfo
/// <summary>
/// Get the IDispatch Typeinfo from CoClass typeinfo.
/// </summary>
/// <param name="typeinfo">Reference to the type info to which the type descriptor belongs</param>
/// <returns>ITypeInfo reference to the Dispatch interface </returns>
internal static COM.ITypeInfo GetDispatchTypeInfoFromCoClassTypeInfo(COM.ITypeInfo typeinfo)
{
//Get the number of interfaces implemented by this CoClass.
COM.TYPEATTR typeattr = GetTypeAttr(typeinfo);
int count = typeattr.cImplTypes;
int href;
COM.ITypeInfo interfaceinfo = null;
//For each interface implemented by this coclass
for (int i = 0; i < count; i++)
{
//Get the type information?
typeinfo.GetRefTypeOfImplType(i, out href);
typeinfo.GetRefTypeInfo(href, out interfaceinfo);
typeattr = GetTypeAttr(interfaceinfo);
// Is this interface IDispatch compatible interface?
if (typeattr.typekind == COM.TYPEKIND.TKIND_DISPATCH)
{
return interfaceinfo;
}
//Nope. Is this a dual interface
if ((typeattr.wTypeFlags & COM.TYPEFLAGS.TYPEFLAG_FDUAL) != 0)
{
interfaceinfo = GetDispatchTypeInfoFromCustomInterfaceTypeInfo(interfaceinfo);
typeattr = GetTypeAttr(interfaceinfo);
if (typeattr.typekind == COM.TYPEKIND.TKIND_DISPATCH)
{
return interfaceinfo;
}
}
}
return null;
}
示例2: GetDispatchTypeInfoFromCustomInterfaceTypeInfo
/// <summary>
///
/// </summary>
/// <param name="typeinfo"></param>
/// <returns></returns>
internal static COM.ITypeInfo GetDispatchTypeInfoFromCustomInterfaceTypeInfo(COM.ITypeInfo typeinfo)
{
int href;
COM.ITypeInfo dispinfo = null;
try
{
// We need the typeinfo for Dispatch Interface
typeinfo.GetRefTypeOfImplType(-1, out href);
typeinfo.GetRefTypeInfo(href, out dispinfo);
}
catch (COMException ce)
{
//check if the error code is TYPE_E_ELEMENTNOTFOUND.
//This error code is thrown when we can't IDispatch interface.
if (ce.HResult != ComUtil.TYPE_E_ELEMENTNOTFOUND)
{
//For other codes, rethrow the exception.
throw;
}
}
return dispinfo;
}