当我尝试从 com 异常中获取 HRESULT 的值时收到警告,我怀疑这是否不是在 C# 中处理 COM 异常的正确方法,请告知代码如下所示。
try
{
...
}
catch (System.Runtime.InteropServices.COMException comex)
{
// Warning 8 Comparison to integral constant is useless; the constant is outside the range of type 'int'
if (comex.ErrorCode == Constants.E_FAIL)
{
}
}
E_FAIL 定义为
public const UInt32 E_FAIL = 0x80004005;