Is there a way to determine if CloseHandle () is the last for a named object?

When creating a named object in the windows, you can find out if the object exists by calling GetLastError() and checking ERROR_ALREADY_EXISTS .

Is there a way to ask a double question: is my CloseHandle() last to close the (descriptor) named resource?

+4
source share
2 answers

Directly, no.

However, you can get this indirectly by calling GetHandleInformation after CloseHandle . If the descriptor is invalid, the function will fail and set the error number ERROR_INVALID_HANDLE .

And no, not indirectly and think about it again. This will only tell you that your descriptor is invalid ... which you already know from the moment you close it.

+1
source

No, kernel handlers are not counted . When you call CloseHandle , it closes the handle.

+2
source

All Articles