【发布时间】:2011-01-21 02:58:24
【问题描述】:
如何使用 Directshow.net 调用此对话框?
【问题讨论】:
标签: filter dialog directshow.net
如何使用 Directshow.net 调用此对话框?
【问题讨论】:
标签: filter dialog directshow.net
假设你有一个 IBaseFilter 参考,这样的事情会起作用:
[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);
}
【讨论】:
Samples\Misc\Toolkit\FilterGraphTools.cs 文件中有此代码。但是如果你不理解这段代码,试着看看 DirectShow 是如何工作的!在这些示例中编译并运行Samples\Players\PlayWnd 项目并探索代码...
请查看 MSDN 中 OleCreatePropertyFrame() 的说明。
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.
必须是:
uint lcid and hr = OleCreatePropertyFrame(form.Handle, 0, 0, info.achName, 1, filters, pages.cElems, pages.pElems, 0, 0, IntPtr.Zero);
【讨论】: