private void GetNamesFromWrapper()
        {
            if (this.TypeLibWrapper != null)
            {
                TLIBATTR[] attr = new TLIBATTR[1];
                attr[0].guid         = this.TypeGuid;
                attr[0].wMajorVerNum = (ushort)this.MajorVersionNumber;
                attr[0].wMinorVerNum = (ushort)this.MinorVersionNumber;
                attr[0].LCID         = Convert.ToUInt32(this.LCID);
                string name;
                if (TypeLibWrapper.GetMainWrapperFriendlyName(attr, out name) == VSConstants.S_OK)
                {
                    this.typeName = name;
                    this.ItemNode.Rename(name);
                }
                if (TypeLibWrapper.GetMainWrapperFilename(attr, out name) == VSConstants.S_OK)
                {
                    this.wrapperFileName = name;
                }
                else
                {
                    Version version = new Version(MajorVersionNumber, MinorVersionNumber);

                    var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("Typelib\\" + TypeGuid.ToString("B") + "\\" + version.ToString());
                    if (key != null)
                    {
                        name = (string)key.GetValue("PrimaryInteropAssemblyName");
                        var asmName  = new AssemblyName(name);
                        var assembly = Assembly.Load(asmName);
                        this.wrapperFileName = assembly.Location;
                    }
                }
            }
            // get the typelib description
            string typeLibPath = QueryPathOfRegTypeLib(this.TypeGuid, (short)MajorVersionNumber, (short)MinorVersionNumber, Convert.ToInt32(this.LCID));

            typeLibPath = typeLibPath.Replace("\0", "");
            if (File.Exists(typeLibPath))
            {
                ITypeLib itypelib;
                int      iresult = LoadTypeLib(typeLibPath, out itypelib);
                if (iresult == VSConstants.S_OK && itypelib != null)
                {
                    System.Runtime.InteropServices.ComTypes.ITypeLib itl = itypelib as System.Runtime.InteropServices.ComTypes.ITypeLib;
                    if (itl != null)
                    {
                        string strName, strDocString, strHelpFile;
                        int    iHelpContext;
                        itl.GetDocumentation(-1, out strName, out strDocString, out iHelpContext, out strHelpFile);
                        description = strDocString;
                    }
                }
            }
        }
예제 #2
0
        private void GetNamesFromWrapper()
        {
            if (this.TypeLibWrapper != null)
            {
                TLIBATTR[] attr = new TLIBATTR[1];
                attr[0].guid         = this.TypeGuid;
                attr[0].wMajorVerNum = (ushort)this.MajorVersionNumber;
                attr[0].wMinorVerNum = (ushort)this.MinorVersionNumber;
                attr[0].LCID         = Convert.ToUInt32(this.LCID);
                string name;
                if (TypeLibWrapper.GetMainWrapperFriendlyName(attr, out name) == VSConstants.S_OK)
                {
                    this.typeName = name;
                    this.ItemNode.Rename(name);
                }
                if (TypeLibWrapper.GetMainWrapperFilename(attr, out name) == VSConstants.S_OK)
                {
                    this.wrapperFileName = name;
                }
            }
            // get the typelib description
            string typeLibPath = QueryPathOfRegTypeLib(this.TypeGuid, (short)MajorVersionNumber, (short)MinorVersionNumber, Convert.ToInt32(this.LCID));

            typeLibPath = typeLibPath.Replace("\0", "");
            if (File.Exists(typeLibPath))
            {
                ITypeLib itypelib;
                int      iresult = LoadTypeLib(typeLibPath, out itypelib);
                if (iresult == VSConstants.S_OK && itypelib != null)
                {
                    System.Runtime.InteropServices.ComTypes.ITypeLib itl = itypelib as System.Runtime.InteropServices.ComTypes.ITypeLib;
                    if (itl != null)
                    {
                        string strName, strDocString, strHelpFile;
                        int    iHelpContext;
                        itl.GetDocumentation(-1, out strName, out strDocString, out iHelpContext, out strHelpFile);
                        description = strDocString;
                    }
                }
            }
        }