public static void Main(string[] args) { System.Runtime.InteropServices.ComTypes.ITypeLib typeLib = null; IntPtr ptr = IntPtr.Zero; string file = arg[0]; try { LoadTypeLib(file, out typeLib); typeLib.GetLibAttr(out ptr); var typeAttr = (System.Runtime.InteropServices.ComTypes.TYPELIBATTR)Marshal.PtrToStructure(ptr, typeof(System.Runtime.InteropServices.ComTypes.TYPELIBATTR)); Console.WriteLine("{0}.{1}", typeAttr.wMajorVerNum, typeAttr.wMinorVerNum); } catch (COMException ex) { Console.WriteLine("Error: " + ex.Message); } finally { if (typeLib != null && ptr != IntPtr.Zero) { typeLib.ReleaseTLibAttr(ptr); } } }
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; } } } }
private void LoadTlb(string tlbFileName) { try { // Load the typelib. System.Runtime.InteropServices.ComTypes.ITypeLib TypeLib = null; APIHelper.LoadTypeLibEx(tlbFileName, REGKIND.REGKIND_DEFAULT, out TypeLib); // Update the tlbTreeView. m_typeLib = new TypeLib((ITypeLib)TypeLib); treeViewTypeLib.SetTypeLibrary(m_typeLib); } catch (Exception) { MessageBox.Show(Resource.FormatString("Wrn_TypeLibLoadFailed", tlbFileName)); } }
private void LoadTlb(string tlbFileName) { try { // Load the typelib. System.Runtime.InteropServices.ComTypes.ITypeLib TypeLib = null; APIHelper.LoadTypeLibEx(tlbFileName, REGKIND.REGKIND_DEFAULT, out TypeLib); // Update the tlbTreeView. TypeLib tlb = new TypeLib((ITypeLib)TypeLib); this.tlbTreeView.SetTypeLibrary(tlb); } catch (Exception) { MessageBox.Show("Err_TypeLibLoad"); } }
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; } } } }
public static extern void LoadTypeLibEx(String strTypeLibName, REGKIND regKind, out System.Runtime.InteropServices.ComTypes.ITypeLib TypeLib);
public static System.Guid GetTypeLibGuid(System.Runtime.InteropServices.ComTypes.ITypeLib typelib) { }
public static string GetTypeLibName(System.Runtime.InteropServices.ComTypes.ITypeLib typelib) { }
public static int GetTypeLibLcid(System.Runtime.InteropServices.ComTypes.ITypeLib typelib) { }
private static extern IntPtr LoadTypeLib(string fileName, out System.Runtime.InteropServices.ComTypes.ITypeLib typeLib);
public static string GetTypeLibName(System.Runtime.InteropServices.ComTypes.ITypeLib typelib) { return(default(string)); }
public static int GetTypeLibLcid(System.Runtime.InteropServices.ComTypes.ITypeLib typelib) { return(default(int)); }
public static Guid GetTypeLibGuid(System.Runtime.InteropServices.ComTypes.ITypeLib typelib) { return(default(Guid)); }