There is a SafeHandleZeroOrMinusOneIsInvalid
class in the .NET Framework, as well as a SafeHandleMinusOneIsInvalid
class.
Why is this? In which situations is zero ever a valid handle?
As additional lecture to the other answers, see this OldNewThing blog entry about inconsistent handle return values.