예제 #1
0
        public static string GetTypeInfoName(ITypeInfo typeInfo)
        {
            ArgumentNullException.ThrowIfNull(typeInfo);

            typeInfo.GetDocumentation(-1, out string strTypeLibName, out _, out _, out _);
            return(strTypeLibName);
        }
예제 #2
0
        private bool CanSkipType(ITypeInfo typeInfo, ITypeLib typeLib, System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttributes, System.Runtime.InteropServices.ComTypes.TYPELIBATTR typeLibAttributes)
        {
            if (((typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IUnknown) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IDispatch)) || (((typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IDispatchEx) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IEnumVariant)) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_ITypeInfo)))
            {
                return(true);
            }
            if (typeLibAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_StdOle)
            {
                string str;
                string str2;
                string str3;
                int    num;
                typeInfo.GetDocumentation(-1, out str, out str2, out num, out str3);
                if (string.CompareOrdinal(str, "GUID") == 0)
                {
                    return(true);
                }
            }
            ITypeLib2 lib = typeLib as ITypeLib2;

            if (lib != null)
            {
                object obj2;
                lib.GetCustData(ref Microsoft.Build.Tasks.NativeMethods.GUID_ExportedFromComPlus, out obj2);
                string str4 = obj2 as string;
                if (!string.IsNullOrEmpty(str4))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
        internal static string GetNameFromFuncDesc(ITypeInfo typeinfo, System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc)
        {
            string strName;

            typeinfo.GetDocumentation(funcdesc.memid, out strName, out string _, out int _, out string _);
            return(strName);
        }
예제 #4
0
 public ComDocumentation(ITypeInfo info, int index)
 {
     info.GetDocumentation(index, out string name, out string docString, out int helpContext, out string helpFile);
     Name        = name;
     DocString   = docString;
     HelpContext = helpContext;
     HelpFile    = helpFile?.Trim('\0');
 }
예제 #5
0
 public ComTypeInfo(ComTypeLibrary comTypeLibrary, ITypeInfo typeInfo, IntPtr pTypeAttr)
 {
     _comTypeLibrary = comTypeLibrary;
     _typeInfo       = typeInfo;
     _pTypeAttr      = pTypeAttr;
     _typeAttr       = _pTypeAttr.ToStructure <System.Runtime.InteropServices.ComTypes.TYPEATTR>();
     _typeInfo.GetDocumentation(-1, out _name, out _description, out _helpContext, out _helpFile);
 }
예제 #6
0
        public unsafe static string?GetMemberName(this ITypeInfo typeInfo, MemberId id)
        {
            BasicString name;

            typeInfo.GetDocumentation(id, &name)
            .ThrowIfFailed($"Failed to get documention for member id: {id.Value}");
            return(name.ToStringAndFree());
        }
예제 #7
0
        private TypeInformation(ITypeInfo nfo)
        {
            nfo.GetDocumentation(-1, out string name, out string desc, out int ctx, out string path);

            Name        = name.StartsWith("_") ? name.Substring(1) : name;
            Description = desc ?? "";
            HelpPath    = path ?? "";
            HelpContext = ctx;
        }
예제 #8
0
        internal static string GetNameFromFuncDesc(ITypeInfo typeinfo, System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc)
        {
            string str;
            string str2;
            string str3;
            int    num;

            typeinfo.GetDocumentation(funcdesc.memid, out str, out str2, out num, out str3);
            return(str);
        }
예제 #9
0
        /// <summary>
        /// Given a managed object that wraps an ITypeInfo, return its name.
        /// </summary>
        public static string GetTypeInfoName(ITypeInfo typeInfo)
        {
            if (typeInfo == null)
            {
                throw new ArgumentNullException(nameof(typeInfo));
            }

            typeInfo.GetDocumentation(-1, out string strTypeLibName, out _, out _, out _);
            return(strTypeLibName);
        }
예제 #10
0
        public static string GetMemberName(this ITypeInfo typeInfo, int memid)
        {
            string name;
            string docString;
            int    helpContext;
            string helpFile;

            typeInfo.GetDocumentation(memid, out name, out docString, out helpContext, out helpFile);
            return(name);
        }
예제 #11
0
        private string GetTypeName(ITypeInfo info)
        {
            string typeName;
            string docString; // todo: put the docString to good use?
            int    helpContext;
            string helpFile;

            info.GetDocumentation(-1, out typeName, out docString, out helpContext, out helpFile);

            return(typeName);
        }
        private string GetTypeName(ITypeInfo info)
        {
            string typeName;
            string docString; // todo: put the docString to good use?
            int    helpContext;
            string helpFile;

            info.GetDocumentation(-1, out typeName, out docString, out helpContext, out helpFile);

            return(typeName.Equals("LONG_PTR") ? "LongPtr" : typeName);  //Quickfix for http://chat.stackexchange.com/transcript/message/30119269#30119269
        }
예제 #13
0
        public MethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
        {
            // Initialise the standard member information.

            string name;
            string docString;
            int    helpContext;
            string helpFile;

            typeInfo.GetDocumentation(funcDesc.memid, out name, out docString, out helpContext, out helpFile);
            Initialise(MemberTypes.Method, name);

            // Get the names of the parameters (index 0 corresponds to the method name itself).

            string[] names = new string[funcDesc.cParams + 1];
            int      nameCount;

            typeInfo.GetNames(funcDesc.memid, names, funcDesc.cParams + 1, out nameCount);

            // Need to account for the return value if there is one.

            bool includeReturnParam = (VarEnum)funcDesc.elemdescFunc.tdesc.vt != VarEnum.VT_VOID &&
                                      (VarEnum)funcDesc.elemdescFunc.tdesc.vt != VarEnum.VT_HRESULT;

            int paramCount = funcDesc.cParams + (includeReturnParam ? 1 : 0);

            m_parameters = new ParameterDesc[paramCount];

            // Iterate over the specified parameters.

            for (int index = 0; index < funcDesc.cParams; ++index)
            {
                // Extract the ELEMDESC.

                IntPtr ptr = (IntPtr)(funcDesc.lprgelemdescParam.ToInt64()
                                      + (long)(Marshal.SizeOf(typeof(ELEMDESC)) * index));
                ELEMDESC elemdesc = (ELEMDESC)Marshal.PtrToStructure(ptr, typeof(ELEMDESC));

                m_parameters[index] = new ParameterDesc(names[index + 1], GetComType(typeInfo, elemdesc.tdesc), elemdesc.desc.idldesc.wIDLFlags);
            }

            // Now add the return value if needed.

            if (includeReturnParam)
            {
                m_parameters[paramCount - 1] = new ParameterDesc("ret", GetComType(typeInfo, funcDesc.elemdescFunc.tdesc) + "*", funcDesc.elemdescFunc.desc.idldesc.wIDLFlags | IDLFLAG.IDLFLAG_FOUT | IDLFLAG.IDLFLAG_FRETVAL);
            }
        }
예제 #14
0
        public static string GetMemberName(ITypeInfo typeInfo, int memberID)
        {
            if (typeInfo == null)
            {
                throw new Exceptions.NullParameterException(typeof(ComInterop), "GetMemberName", "typeInfo");
            }

            string name;
            string docString;
            int    helpContext;
            string helpFile;

            typeInfo.GetDocumentation(memberID, out name, out docString, out helpContext, out helpFile);

            return(name);
        }
예제 #15
0
        /// <summary>
        /// Returns true if we don't need to analyze this particular type.
        /// </summary>
        /// <param name="typeInfo"></param>
        /// <param name="typeLib"></param>
        /// <param name="typeAttributes"></param>
        /// <param name="typeLibAttributes"></param>
        /// <returns></returns>
        private bool CanSkipType(ITypeInfo typeInfo, ITypeLib typeLib, TYPEATTR typeAttributes, TYPELIBATTR typeLibAttributes)
        {
            // Well known OLE type?
            if ((typeAttributes.guid == NativeMethods.IID_IUnknown) ||
                (typeAttributes.guid == NativeMethods.IID_IDispatch) ||
                (typeAttributes.guid == NativeMethods.IID_IDispatchEx) ||
                (typeAttributes.guid == NativeMethods.IID_IEnumVariant) ||
                (typeAttributes.guid == NativeMethods.IID_ITypeInfo))
            {
                return(true);
            }

            // Is this the Guid type? If so we should be using the corresponding .NET type.
            if (typeLibAttributes.guid == NativeMethods.IID_StdOle)
            {
                string typeName, ignoredDocString, ignoredHelpFile;
                int    ignoredHelpContext;

                typeInfo.GetDocumentation(-1, out typeName, out ignoredDocString, out ignoredHelpContext, out ignoredHelpFile);

                if (string.CompareOrdinal(typeName, "GUID") == 0)
                {
                    return(true);
                }
            }

            // Skip types exported from .NET assemblies
            ITypeLib2 typeLib2 = typeLib as ITypeLib2;

            if (typeLib2 != null)
            {
                object exportedFromComPlusObj;
                typeLib2.GetCustData(ref NativeMethods.GUID_ExportedFromComPlus, out exportedFromComPlusObj);

                string exportedFromComPlus = exportedFromComPlusObj as string;

                if (!string.IsNullOrEmpty(exportedFromComPlus))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #16
0
        private void LoadDocumentation(ITypeLib typeLib, ITypeInfo info, int index)
        {
            string name;
            string docString;
            int    helpContext;
            string helpFile;

            if (info == null)
            {
                typeLib.GetDocumentation(index, out name, out docString, out helpContext, out helpFile);
            }
            else
            {
                info.GetDocumentation(index, out name, out docString, out helpContext, out helpFile);
            }

            //See http://chat.stackexchange.com/transcript/message/30119269#30119269
            Name        = name;
            DocString   = docString;
            HelpContext = helpContext;
            HelpFile    = helpFile;
        }
예제 #17
0
        public FieldDesc(ITypeInfo typeInfo, Win32.VARDESC varDesc)
        {
            string name;
            string docString;
            int    helpContext;
            string helpFile;

            typeInfo.GetDocumentation(varDesc.memid, out name, out docString, out helpContext, out helpFile);

            Initialise(MemberTypes.Field, name);

            m_type = GetComType(typeInfo, varDesc.elemdescVar.tdesc);

            if (varDesc.varkind == Win32.VARKIND.VAR_CONST)
            {
                object fieldValue = Marshal.GetObjectForNativeVariant(varDesc.descUnion.lpvarValue);
                Debug.Assert(fieldValue != null, "fieldValue != null");
                m_value = fieldValue.ToString();
            }
            else
            {
                m_value = null;
            }
        }
예제 #18
0
        public static Dictionary <string, string> GetHelpStrings(Assembly assembly)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            var a = assembly.CustomAttributes.FirstOrDefault(x => x.AttributeType.Equals(typeof(ImportedFromTypeLibAttribute)));
            var b = assembly.CustomAttributes.FirstOrDefault(x => x.AttributeType.Equals(typeof(GuidAttribute)));
            var c = assembly.CustomAttributes.FirstOrDefault(x => x.AttributeType.Equals(typeof(TypeLibVersionAttribute)));

            if (a != null)
            {
                Guid guid      = Guid.Parse(String.Format("{0}", b.ConstructorArguments[0].Value));
                int  wVerMajor = (int)c.ConstructorArguments[0].Value;
                int  wVerMinor = (int)c.ConstructorArguments[1].Value;

                ITypeLib typeLib = null;
                typeLib = LoadRegTypeLib(ref guid, wVerMajor, wVerMinor, 0);

                string strLibName       = null;
                string strLibDocString  = null;
                int    dwLibHelpContext = 0;
                string strLibHelpFile   = null;

                typeLib.GetDocumentation(-1, out strLibName, out strLibDocString, out dwLibHelpContext, out strLibHelpFile);

                int count = typeLib.GetTypeInfoCount();

                // Loop through types.
                for (int i = 0; i < count; i++)
                {
                    ITypeInfo typeInfo = null;
                    typeLib.GetTypeInfo(i, out typeInfo);

                    IntPtr pTypeAttr = IntPtr.Zero;

                    typeInfo.GetTypeAttr(out pTypeAttr);
                    System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = (System.Runtime.InteropServices.ComTypes.TYPEATTR)Marshal.PtrToStructure(pTypeAttr, typeof(System.Runtime.InteropServices.ComTypes.TYPEATTR));

                    // Skip type if it is hidden.
                    if (typeAttr.wTypeFlags.HasFlag(System.Runtime.InteropServices.ComTypes.TYPEFLAGS.TYPEFLAG_FHIDDEN) == true)
                    {
                        continue;
                    }

                    string strTypeName       = null;
                    string strTypeDocString  = null;
                    int    dwTypeHelpContext = 0;
                    string strTypeHelpFile   = null;

                    typeInfo.GetDocumentation(-1, out strTypeName, out strTypeDocString, out dwTypeHelpContext, out strTypeHelpFile);

                    string typeKey = String.Format("{0}.{1}", strLibName, strTypeName);
                    dictionary.Add(typeKey, strTypeDocString);

                    for (int j = 0; j < typeAttr.cFuncs; j++)
                    {
                        IntPtr pFuncDesc = IntPtr.Zero;
                        typeInfo.GetFuncDesc(j, out pFuncDesc);

                        System.Runtime.InteropServices.ComTypes.FUNCDESC funcDesc = (System.Runtime.InteropServices.ComTypes.FUNCDESC)Marshal.PtrToStructure(pFuncDesc, typeof(System.Runtime.InteropServices.ComTypes.FUNCDESC));

                        string strMemberName       = null;
                        string strMemberDocString  = null;
                        int    dwMemberHelpContext = 0;
                        string strMemberHelpFile   = null;

                        typeInfo.GetDocumentation(funcDesc.memid, out strMemberName, out strMemberDocString, out dwMemberHelpContext, out strMemberHelpFile);

                        string memberKey = String.Format("{0}.{1}", typeKey, strMemberName);

                        if (!dictionary.ContainsKey(memberKey))
                        {
                            dictionary.Add(memberKey, strMemberDocString);
                        }

                        typeInfo.ReleaseFuncDesc(pFuncDesc);
                    }

                    typeInfo.ReleaseTypeAttr(pTypeAttr);
                }
            }

            return(dictionary);
        }
예제 #19
0
파일: ComUtil.cs 프로젝트: nickchal/pash
 internal static string GetNameFromFuncDesc(ITypeInfo typeinfo, System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc)
 {
     string str;
     string str2;
     string str3;
     int num;
     typeinfo.GetDocumentation(funcdesc.memid, out str, out str2, out num, out str3);
     return str;
 }
예제 #20
0
 public ComTypeInfo(ComTypeLibrary comTypeLibrary, ITypeInfo typeInfo, IntPtr pTypeAttr)
 {
     _comTypeLibrary = comTypeLibrary;
     _typeInfo = typeInfo;
     _pTypeAttr = pTypeAttr;
     _typeAttr = _pTypeAttr.ToStructure<System.Runtime.InteropServices.ComTypes.TYPEATTR>();
     _typeInfo.GetDocumentation(-1, out _name, out _description, out _helpContext, out _helpFile);
 }
예제 #21
0
 public static string GetMemberName(this ITypeInfo typeInfo, int memid)
 {
     typeInfo.GetDocumentation(memid, out var name, out _, out _, out _);
     return(name);
 }
 private bool CanSkipType(ITypeInfo typeInfo, ITypeLib typeLib, System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttributes, System.Runtime.InteropServices.ComTypes.TYPELIBATTR typeLibAttributes)
 {
     if (((typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IUnknown) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IDispatch)) || (((typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IDispatchEx) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IEnumVariant)) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_ITypeInfo)))
     {
         return true;
     }
     if (typeLibAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_StdOle)
     {
         string str;
         string str2;
         string str3;
         int num;
         typeInfo.GetDocumentation(-1, out str, out str2, out num, out str3);
         if (string.CompareOrdinal(str, "GUID") == 0)
         {
             return true;
         }
     }
     ITypeLib2 lib = typeLib as ITypeLib2;
     if (lib != null)
     {
         object obj2;
         lib.GetCustData(ref Microsoft.Build.Tasks.NativeMethods.GUID_ExportedFromComPlus, out obj2);
         string str4 = obj2 as string;
         if (!string.IsNullOrEmpty(str4))
         {
             return true;
         }
     }
     return false;
 }
예제 #23
0
 public static string GetDocumentationById(this ITypeInfo ti, int memid)
 {
     ti.GetDocumentation(memid, out var res, out _, out var _, out _);
     return(res);
 }
예제 #24
0
        public override void asCommandLine(Dictionary <string, string> args)
        {
            _typeLibrary = (string)args["TypeLibrary"];
            //_typeLibrary = @"C:\Peach3\ComTest\Release\ComTest.dll";

            if (!File.Exists(_typeLibrary))
            {
                throw new PeachException("Error, the TypeLibrary was not found.");
            }

            ITypeLib typeLib = null;
            int      ret     = LoadTypeLib(_typeLibrary, out typeLib);

            if (ret != 0)
            {
                throw new PeachException("Error loading TypeLibrary.  LoadTypeLib returned " + ret);
            }

            if (typeLib == null)
            {
                throw new PeachException("Error, LoadTypeLib returned a null ITypeLib interface.");
            }

            string name;
            string doc;
            int    helpid;
            string helpfile;

            string [] arrClassification = new string [] { "Enum", "Struct", "Module", "Interface",
                                                          "Dispinterface", "Coclass", "Typedef", "Union" };


            typeLib.GetDocumentation(-1, out name, out doc, out helpid, out helpfile);
            Console.WriteLine(name);

            ITypeInfo typeInfo = null;

            for (int cnt = 0; cnt < typeLib.GetTypeInfoCount(); cnt++)
            {
                // http://www.codeguru.com/cpp/com-tech/activex/misc/article.php/c2569

                Console.WriteLine(" ------------- ");

                typeInfo = null;
                typeLib.GetTypeInfo(cnt, out typeInfo);
                if (typeInfo == null)
                {
                    Console.WriteLine("typeInfo was null, continue!");
                    continue;
                }

                typeLib.GetDocumentation(cnt, out name, out doc, out helpid, out helpfile);
                Console.WriteLine("  " + name);

                System.Runtime.InteropServices.ComTypes.TYPEKIND typeKind;
                typeLib.GetTypeInfoType(cnt, out typeKind);

                Console.WriteLine("  " + arrClassification[(int)typeKind]);

                IntPtr ppTypeAttributes;
                typeInfo.GetTypeAttr(out ppTypeAttributes);
                var typeAttributes = (System.Runtime.InteropServices.ComTypes.TYPEATTR)Marshal.PtrToStructure(ppTypeAttributes, typeof(System.Runtime.InteropServices.ComTypes.TYPEATTR));

                for (int cntFuncs = 0; cntFuncs < typeAttributes.cFuncs; cntFuncs++)
                {
                    IntPtr ppFuncDesc;
                    typeInfo.GetFuncDesc(cntFuncs, out ppFuncDesc);
                    var funcDesc = (System.Runtime.InteropServices.ComTypes.FUNCDESC)Marshal.PtrToStructure(ppFuncDesc, typeof(System.Runtime.InteropServices.ComTypes.FUNCDESC));

                    int memberID = funcDesc.memid;
                    //var elemDesc = funcDesc.elemdescFunc;

                    typeInfo.GetDocumentation(memberID, out name, out doc, out helpid, out helpfile);
                    Console.WriteLine("    " + name);

                    //funcDesc.

                    typeInfo.ReleaseFuncDesc(ppFuncDesc);
                }

                for (int cntVars = 0; cntVars < typeAttributes.cVars; cntVars++)
                {
                    IntPtr ppVarDesc;
                    typeInfo.GetVarDesc(cntVars, out ppVarDesc);
                    var varDesc = (System.Runtime.InteropServices.ComTypes.VARDESC)Marshal.PtrToStructure(ppVarDesc, typeof(System.Runtime.InteropServices.ComTypes.VARDESC));

                    int memberID = varDesc.memid;

                    typeInfo.GetDocumentation(memberID, out name, out doc, out helpid, out helpfile);
                    Console.WriteLine("    " + name);

                    typeInfo.ReleaseVarDesc(ppVarDesc);
                }

                typeInfo.ReleaseTypeAttr(ppTypeAttributes);
            }
        }
예제 #25
0
 public static string GetHelpDocumentationById(this ITypeInfo ti, int memid, out int context)
 {
     ti.GetDocumentation(memid, out _, out var res, out context, out _);
     return(res);
 }