如何从c#调用OleCreatePropertyFrameIndirect

时间:2012-02-10 10:44:05

标签: c# winapi c++-cli directx directshow

我正在用c#编写一个需要显示属性页的应用程序。我有代码:

ISpecifyPropertyPages pProp = sourceObject as ISpecifyPropertyPages;
int hr = 0;

//Get the name of the filter from the FilterInfo struct
FilterInfo filterInfo;
hr = ((IBaseFilter) sourceObject).QueryFilterInfo(out filterInfo);
//DsError.ThrowExceptionForHR(hr);
if (hr == 0)
{
// Get the propertypages from the property bag
CAUUID caGUID;
hr = pProp.GetPages(out caGUID);

if (hr == 0)
{
    // Create and display the OlePropertyFrame
    hr = Win32.OleCreatePropertyFrame(parentWindowForPropertyPage, 0, 0,
                      filterInfo.achName, 1,ref sourceObject,
                      caGUID.cElems,
                      caGUID.pElems, 0, 0, IntPtr.Zero);
}
// Release COM objects
Marshal.ReleaseComObject(pProp);
Marshal.FreeCoTaskMem(caGUID.pElems);
}

...如果源未运行,则工作正常 - 如果源正在运行,则属性窗口会闪烁并立即退出。我猜我需要使用OleCreatePropertyFrameIndirect并用现有对象调用它,但我找不到任何通过c#做的例子 - 任何想法?

1 个答案:

答案 0 :(得分:0)

OleCreatePropertyFrameIndirect不太可能出现问题。更有可能的是,属性页本身(和/或源过滤器)有问题并关闭,抛出异常,生成访问冲突等。