本文整理汇总了C#中System.Runtime.InteropServices.ComTypes.GetRefTypeInfo方法的典型用法代码示例。如果您正苦于以下问题:C# ComTypes.GetRefTypeInfo方法的具体用法?C# ComTypes.GetRefTypeInfo怎么用?C# ComTypes.GetRefTypeInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.InteropServices.ComTypes
的用法示例。
在下文中一共展示了ComTypes.GetRefTypeInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GetStringFromCustomType
/// <summary>
/// Gets the name of the custom type defined in the type library
/// </summary>
/// <param name="typeinfo">ITypeInfo interface of the type</param>
/// <param name="refptr">reference to the custom type</param>
/// <returns>name of the custom type</returns>
private static string GetStringFromCustomType(COM.ITypeInfo typeinfo, IntPtr refptr)
{
COM.ITypeInfo custtypeinfo;
int reftype = unchecked((int)(long)refptr); // note that we cast to long first to prevent overflows; this cast is OK since we are only interested in the lower word
typeinfo.GetRefTypeInfo(reftype, out custtypeinfo);
if (custtypeinfo != null)
{
String strName, strDoc, strHelp;
int id;
custtypeinfo.GetDocumentation(-1, out strName, out strDoc, out id, out strHelp);
return strName;
}
return "UnknownCustomtype";
}
示例3: 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;
}