/// <summary>
        /// 打开摄像头配置页面
        /// 系统原生方式
        /// </summary>
        public void ChangeCameraSetting()
        {
            DsCAUUID cauuid = new DsCAUUID();

            try
            {
                specifyPropertyPages = _theCamera as ISpecifyPropertyPages;
                if (specifyPropertyPages == null)
                {
                    MessageBox.Show("请先打开视频设备!");
                    return;
                }
                //返回filter所支持的属性页的CLSID
                int hr = specifyPropertyPages.GetPages(out cauuid);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                object o = specifyPropertyPages;
                //获取属性页
                hr = OleCreatePropertyFrame(this._priviewControlHandle, 30, 30, null, 1,
                                            ref o, cauuid.cElems, cauuid.pElems, 0, 0, IntPtr.Zero);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable display property page. Please submit a bug report.\n\n" + ex.Message + "\n\n" + ex.ToString());
            }
        }
Beispiel #2
0
        public static bool ShowTunerPinDialog(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(IAMTVTuner).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;
            }
        }