Prev Next

CloseHandle info  Overview  Group

The CloseHandle function closes an open object handle.

BOOL CloseHandle(

    HANDLE hObject 

// handle to object to close

   );

Parameters

hObject
Identifies an open object handle.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The CloseHandle function closes handles to the following objects:

CloseHandle invalidates the specified object handle, decrements the object’s handle count, and performs object retention checks. Once the last handle to an object is closed, the object is removed from the operating system.

This function does not close module objects.

Use CloseHandle to close handles returned by calls to the CreateFile function. Use FindClose to close handles returned by calls to the FindFirstFile function.

Closing an invalid handle raises an exception. This includes closing a handle twice, not checking the return value and closing an invalid handle, and using CloseHandle on a handle returned by FindFirstFile.

See Also

CreateFile, DeleteFile, FindClose, FindFirstFile

See: