C# : How to use directshow.net to show this dialog?

元气小坏坏 提交于 2019-12-06 21:22:36
David Paxson

Something like this would work, assuming you have an IBaseFilter reference:

[DllImport("oleaut32.dll", CharSet = CharSet.Auto)]
    internal static extern int OleCreatePropertyFrame(
        IntPtr hwndOwner,
        uint x, uint y,
        [MarshalAs(UnmanagedType.LPWStr)]
        string caption,
        uint objectCount,
        [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.IUnknown)]
        object[] lplpUnk,
        int cPages,
        IntPtr pageClsID,
        Guid lcid,
        uint dwReserved,
        IntPtr lpvReserved);

    public void DisplayPropertyPages(Form form, IBaseFilter filter)
    {
            var propertyPages = filter as ISpecifyPropertyPages;
            DsCAUUID pages;
            FilterInfo info;
            int hr = filter.QueryFilterInfo(out info);
            DsError.ThrowExceptionForHR(hr);
            if (propertyPages == null)
            {
                throw new ApplicationException("IBaseFilter doesn't implement ISpecifyPropertyPages");
            }
            hr = propertyPages.GetPages(out pages);
            DsError.ThrowExceptionForHR(hr);
            var filters = new IBaseFilter[1];
            filters[0] = filter;
            hr = OleCreatePropertyFrame(form.Handle, 0, 0, info.achName, 1, filters,
                pages.cElems, pages.pElems, Guid.Empty, 0, IntPtr.Zero);
            Marshal.FreeCoTaskMem(pages.pElems);
            DsError.ThrowExceptionForHR(hr);
    }

Please, check description of OleCreatePropertyFrame() in MSDN.

Guid lcid is invalid. Result: Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'D:\CVS\Dev\Filters\H264\H264mfxEncoder\Samples\C#\H264EncoderTest\bin\Debug\H264EncoderTest.vshost.exe'. Additional Information: A call to PInvoke function 'H264EncoderTest!H264EncoderTest.CGraph::OleCreatePropertyFrame' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Must be: uint lcid and hr = OleCreatePropertyFrame(form.Handle, 0, 0, info.achName, 1, filters, pages.cElems, pages.pElems, 0, 0, IntPtr.Zero);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!