(preliminary note: I'm not yet fully up to speed with the whole 'interop' thing...)
When using a COM library from within .NET, all HRESULT
methods are wrapped into something that throws when the return code is not SUCCEEDED.
//ATL magic exluded
class C {
HRESULT foo(){ return E_FAIL; }
};
// usage code:
if( SUCCEEDED( c.foo() ) ) {
// success code
} else {
// failure code
}
The .NET counterpart of this code reads:
try {
c.foo();
// success code
} catch ( Exception e ) {
// failure code
}
Is there a way to access the COM return code directly in .NET, so that no exception handling is needed?