我正在使用来自c#的GMFBridge directshow过滤器,导入库似乎丢弃了HRESULT。即
[id(5), helpstring("Create render filters in empty render graph")]
HRESULT CreateRenderGraph(
[in] IUnknown* pSourceGraphSinkFilter,
[in] IUnknown* pRenderGraph,
[out, retval] IUnknown** pRenderGraphSourceFilter);
[id(6), helpstring("Connect two graphs")]
HRESULT BridgeGraphs(
[in] IUnknown* pSourceGraphSinkFilter,
[in] IUnknown* pRenderGraphSourceFilter);
(由midl.exe和tlbimp.exe翻译)到:
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime), DispId(5)]
object CreateRenderGraph([In, MarshalAs(UnmanagedType.IUnknown)] object pSourceGraphSinkFilter, [In, MarshalAs(UnmanagedType.IUnknown)] object pRenderGraph);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime), DispId(6)]
void BridgeGraphs([In, MarshalAs(UnmanagedType.IUnknown)] object pSourceGraphSinkFilter, [In, MarshalAs(UnmanagedType.IUnknown)] object pRenderGraphSourceFilter);
我导入的其他COM库将返回值转换为out参数,并保留原始COM方法的HRESULT返回值。为什么这个库表现不同?是否有可能强迫其他行为?
谢谢, 安迪
答案 0 :(得分:0)
.NET约定是将[out, retval]
转换为C#返回值,并将失败的HRESULT转换为COMException
个对象,并使用ErrorCode
属性中的HRESULT。如果你想看到非错误的HRESULT,我认为你被困了。
我有兴趣看到翻译后产生原始HRESULT的方法的IDL声明 - 你问题中的例子是我希望看到的正常情况。