Beispiel #1
0
        public static bool ShowCapPinDialog(ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd)
        {
            int    hr;
            object comObj = null;
            ISpecifyPropertyPages spec = null;
            DsCAUUID cauuid            = new DsCAUUID();

            try
            {
                Guid cat  = PinCategory.Capture;
                Guid type = MediaType.Interleaved;
                Guid iid  = typeof(IAMStreamConfig).GUID;
                hr = bld.FindInterface(ref cat, ref type, flt, ref iid, out comObj);
                if (hr != 0)
                {
                    type = MediaType.Video;
                    hr   = bld.FindInterface(ref cat, ref type, flt, ref iid, out comObj);
                    if (hr != 0)
                    {
                        return(false);
                    }
                }
                spec = comObj as ISpecifyPropertyPages;
                if (spec == null)
                {
                    return(false);
                }

                hr = spec.GetPages(out cauuid);
                hr = OleCreatePropertyFrame(hwnd, 30, 30, null, 1,
                                            ref comObj, cauuid.cElems, cauuid.pElems, 0, 0, IntPtr.Zero);
                return(true);
            }
            catch (Exception ee)
            {
                Trace.WriteLine("!Ds.NET: ShowCapPinDialog " + ee.Message);
                return(false);
            }
            finally
            {
                if (cauuid.pElems != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(cauuid.pElems);
                }

                spec = null;
                if (comObj != null)
                {
                    Marshal.ReleaseComObject(comObj);
                }
                comObj = null;
            }
        }
Beispiel #2
0
        public static bool ShowCapPinDialog(ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd)
        {
            int hr;
            object comObj = null;
            ISpecifyPropertyPages spec = null;
            DsCAUUID cauuid = new DsCAUUID();

            try
            {
                Guid cat = PinCategory.Capture;
                Guid type = MediaType.Interleaved;
                Guid iid = typeof(IAMStreamConfig).GUID;
                hr = bld.FindInterface(ref cat, ref type, flt, ref iid, out comObj);
                if (hr != 0)
                {
                    type = MediaType.Video;
                    hr = bld.FindInterface(ref cat, ref type, flt, ref iid, out comObj);
                    if (hr != 0)
                        return false;
                }
                spec = comObj as ISpecifyPropertyPages;
                if (spec == null)
                    return false;

                hr = spec.GetPages(out cauuid);
                hr = OleCreatePropertyFrame(hwnd, 30, 30, null, 1,
                        ref comObj, cauuid.cElems, cauuid.pElems, 0, 0, IntPtr.Zero);
                return true;
            }
            catch (Exception ee)
            {
                Trace.WriteLine("!Ds.NET: ShowCapPinDialog " + ee.Message);
                return false;
            }
            finally
            {
                if (cauuid.pElems != IntPtr.Zero)
                    Marshal.FreeCoTaskMem(cauuid.pElems);

                spec = null;
                if (comObj != null)
                    Marshal.ReleaseComObject(comObj); comObj = null;
            }
        }