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


C# ComTypes.GetRefTypeInfo方法代码示例

本文整理汇总了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;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:41,代码来源:ComTypeInfo.cs

示例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";
        }
开发者ID:40a,项目名称:PowerShell,代码行数:22,代码来源:ComUtil.cs

示例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;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:28,代码来源:ComTypeInfo.cs


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