I've seen a lot of example c++ code that wraps function calls in a FAILED() function/method/macro. Could someone explain to me how this works? And if possible does anyone know a c# equivalent?
It generally checks COM function errors. But checking any function that returns a HRESULT
is what it's meant for, specifically. FAILED
returns a true value if the HRESULT
value is negative, which means that the function failed ("error" or "warning" severity). Both S_OK
and S_FALSE
are >= 0 and so they are not used to convey an error. With "negative" I mean that the high bit is set for HRESULT
error codes, i.e., their hexadecimal representation, which can be found in, e.g., winerror.h, begins with an 8, as in 0x8000FFFF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With