public static string GetManagedName(this ITypeLib typeLib) { if (typeLib is ITypeLib2 typeLib2) { // ReSharper disable EmptyGeneralCatchClause try { var guid = managedNameGuid; typeLib2.GetCustData(ref guid, out var data); if (data is string name) { name = name.Trim(); if (name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { return(name.Substring(0, name.Length - 4)); } return(name); } } catch (Exception) { } // ReSharper restore EmptyGeneralCatchClause } return(typeLib.GetName()); }
private static string GetManagedTypeLibName(ITypeLib typeLib) { var typeLib2 = typeLib as ITypeLib2; if (typeLib2 != null) { // ReSharper disable EmptyGeneralCatchClause try { var guid = managedNameGuid; object data; typeLib2.GetCustData(ref guid, out data); var name = data as string; if (name != null) { name = name.Trim(); if (name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { return(name.Substring(0, name.Length - 4)); } return(name); } } catch (Exception) { } // ReSharper restore EmptyGeneralCatchClause } return(typeLib.GetName()); }
public OWTypeLib(ITypeLib tlib) { _tlib = tlib; _name = _tlib.GetName(); _name += " (" + _tlib.GetHelpDocumentation(out _) + ")"; _data = new IDLData(this); }
public OWTypeLib(string path) { NativeMethods.LoadTypeLib(path, out _tlib); if (_tlib == null) { throw new Exception(path + " is not a loadable typelibrary."); } _name = _tlib.GetName(); _name += " (" + _tlib.GetHelpDocumentation(out _) + ")"; }