Esempio n. 1
0
        /// <summary>
        /// Create a list of DSGrapheditROTEntry from IFilterGraphs on the ROT
        /// </summary>
        /// <returns></returns>
        public static List <DSGrapheditROTEntry> GetFilterGraphsFromROT()
        {
            IRunningObjectTable        rtt     = null;
            IEnumMoniker               enumMon = null;
            List <DSGrapheditROTEntry> rots    = new List <DSGrapheditROTEntry>();

            int hr = GetRunningObjectTable(0, out rtt);

            rtt.EnumRunning(out enumMon);
            enumMon.Reset();
            if (hr != 1)
            {
                try
                {
                    IMoniker[] mon = new IMoniker[1];
                    while ((enumMon.Next(1, mon, IntPtr.Zero) == 0))
                    {
                        try
                        {
                            IBindCtx pctx; string displayName;
                            CreateBindCtx(0, out pctx);
                            // Get the name of the file
                            mon[0].GetDisplayName(pctx, null, out displayName);
                            // Clean up
                            Marshal.ReleaseComObject(pctx);
                            if (displayName.StartsWith("!FilterGraph"))
                            {
                                DSGrapheditROTEntry ds1 = new DSGrapheditROTEntry(displayName, mon[0]);
                                if (ds1._processName == "MediaPortal")
                                {
                                    rots.Add(ds1);
                                }
                                else
                                {
                                    ds1.Dispose();
                                }
                            }
                            else
                            {
                                Marshal.ReleaseComObject(mon[0]);
                            }
                        }
                        catch
                        {
                            Marshal.ReleaseComObject(mon[0]);
                            //throw;
                        }
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(enumMon);
                }
            }

            return(rots);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a list of DSGrapheditROTEntry from IFilterGraphs on the ROT
        /// </summary>
        /// <returns></returns>
        public static List<DSGrapheditROTEntry> GetFilterGraphsFromROT()
        {
            IRunningObjectTable rtt = null;
            IEnumMoniker enumMon = null;
            List<DSGrapheditROTEntry> rots = new List<DSGrapheditROTEntry>();

            int hr = GetRunningObjectTable(0, out rtt);
            rtt.EnumRunning(out enumMon);
            enumMon.Reset();
            if (hr != 1)
            {
                try
                {
                    IMoniker[] mon = new IMoniker[1];
                    while ((enumMon.Next(1, mon, IntPtr.Zero) == 0))
                    {
                        try
                        {
                            IBindCtx pctx; string displayName;
                            CreateBindCtx(0, out pctx);
                            // Get the name of the file
                            mon[0].GetDisplayName(pctx, null, out displayName);
                            // Clean up
                            Marshal.ReleaseComObject(pctx);
                            if (displayName.StartsWith("!FilterGraph"))
                            {
                                DSGrapheditROTEntry ds1 = new DSGrapheditROTEntry(displayName, mon[0]);
                                if (ds1._processName == "MediaPortal")
                                  rots.Add(ds1);
                                else
                                  ds1.Dispose();
                            }
                            else
                            {
                                Marshal.ReleaseComObject(mon[0]);
                            }
                        }
                        catch
                        {
                            Marshal.ReleaseComObject(mon[0]);
                            //throw;
                        }
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(enumMon);
                }
            }

            return rots;
        }