Question

Fact 1: Due to some client-constraints we are unable to use Exception mechanism.

Fact 2: Closing a handle which was already closed raises an Exception.

Without going through the reasons for the mention facts, will calling GetHandleInformation() to detect whether or not the handle is still valid, and only if it is calling CloseHandle() would be a good way of avoiding such an exception?

Was it helpful?

Solution

You must not access a closed handle in any way, as it may refer to a different handle due to handle recycling.

handle recycling means that any invalid handle can suddenly become valid again (but refer to an unrelated object).

Raymond Chen - The Old New Thing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top