예제 #1
0
        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());
        }
예제 #2
0
        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());
        }
예제 #3
0
        public OWTypeLib(ITypeLib tlib)
        {
            _tlib  = tlib;
            _name  = _tlib.GetName();
            _name += " (" + _tlib.GetHelpDocumentation(out _) + ")";

            _data = new IDLData(this);
        }
예제 #4
0
 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 _) + ")";
 }