如何使用Directshow.net调用此对话框?
答案 0 :(得分:5)
假设你有一个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);
}
答案 1 :(得分:1)
请检查MSDN中OleCreatePropertyFrame()的说明。
Guid lcid无效。结果: 托管调试助手'PInvokeStackImbalance'在'D:\ CVS \ Dev \ Filters \ H264 \ H264mfxEncoder \ Samples \ C#\ H264EncoderTest \ bin \ Debug \ H264EncoderTest.vshost.exe'中检测到问题。 附加信息:调用PInvoke函数'H264EncoderTest!H264EncoderTest.CGraph :: OleCreatePropertyFrame'使堆栈失衡。这很可能是因为托管PInvoke签名与非托管目标签名不匹配。检查PInvoke签名的调用约定和参数是否与目标非托管签名匹配。
必须是:uint lcid 和hr = OleCreatePropertyFrame(form.Handle,0,0,info.achName,1,filters,pages.cElems,pages.pElems,0,0,IntPtr.Zero);