CloseHandle

  BOOL CloseHandle(hObject)    
  HANDLE hObject; /* object handle to close */

The CloseHandle function closes an open object handle.

Parameters

hObject

Identifies an open handle to an object.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

The following objects can be closed using the CloseHandle function:

console input or output

event

file (including file mappings)

mutex

named pipe handle

process

semaphore

thread

Closing an open handle to an object causes the handle to become invalid. The handle count of the associated object is decremented and object retention checks are performed. Once the last open handle to an object is closed, the object is removed from the system.

Note that this function cannot be used to close module objects.