/// <summary> /// Luoz: create the used COM components and get the interfaces /// </summary> /// <returns></returns> bool GetInterfaces() { Type comType = null; object comObj = null; try { comType = Type.GetTypeFromCLSID(prp.Clsid.FilterGraph); if (comType == null) { throw new NotImplementedException(@"DirectShow FilterGraph not installed/registered!"); } comObj = Activator.CreateInstance(comType); graphBuilder = (prp.IGraphBuilder)comObj; comObj = null; //Guid clsid = Clsid.CaptureGraphBuilder2; //Guid riid = typeof(ICaptureGraphBuilder2).GUID; //comObj = DsBugWO.CreateDsInstance(ref clsid, ref riid); //capGraph = (ICaptureGraphBuilder2)comObj; comObj = null; comType = Type.GetTypeFromCLSID(prp.Clsid.CaptureGraphBuilder2); comObj = Activator.CreateInstance(comType); capGraph = (prp.ICaptureGraphBuilder2)comObj; comObj = null; mediaCtrl = (prp.IMediaControl)graphBuilder; videoWin = (prp.IVideoWindow)graphBuilder; mediaEvt = (prp.IMediaEventEx)graphBuilder; return(true); } catch (Exception ee) { MessageBox.Show(this, "Could not get interfaces\r\n" + ee.Message, "DirectShow.NET", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } finally { if (comObj != null) { Marshal.ReleaseComObject(comObj); } comObj = null; } }
/// <summary> /// Luoz: create the used COM components and get the interfaces /// </summary> /// <returns></returns> bool GetInterfaces() { Type comType = null; object comObj = null; try { comType = Type.GetTypeFromCLSID(prp.Clsid.FilterGraph); if (comType == null) throw new NotImplementedException(@"DirectShow FilterGraph not installed/registered!"); comObj = Activator.CreateInstance(comType); graphBuilder = (prp.IGraphBuilder)comObj; comObj = null; //Guid clsid = Clsid.CaptureGraphBuilder2; //Guid riid = typeof(ICaptureGraphBuilder2).GUID; //comObj = DsBugWO.CreateDsInstance(ref clsid, ref riid); //capGraph = (ICaptureGraphBuilder2)comObj; comObj = null; comType = Type.GetTypeFromCLSID(prp.Clsid.CaptureGraphBuilder2); comObj = Activator.CreateInstance(comType); capGraph = (prp.ICaptureGraphBuilder2)comObj; comObj = null; mediaCtrl = (prp.IMediaControl)graphBuilder; videoWin = (prp.IVideoWindow)graphBuilder; mediaEvt = (prp.IMediaEventEx)graphBuilder; return true; } catch (Exception ee) { MessageBox.Show(this, "Could not get interfaces\r\n" + ee.Message, "DirectShow.NET", MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } finally { if (comObj != null) Marshal.ReleaseComObject(comObj); comObj = null; } }