A version of this page is also available for
This function closes an open object handle. A remote API (RAPI) version of this function exists called CeCloseHandle (RAPI).
BOOL CloseHandle( HANDLE hObject );
[in] Handle to an open object.
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
This function closes handles to the following objects:
- Communications device
- Database enumeration context
- File-mapping object
This function invalidates the specified object handle, decrements the object's handle count, and performs object retention checks. After the last handle to an object is closed, the object is removed from the system. Persistent objects, such as databases and files, remain in storage, but must be re-opened to be accessed again.
Closing a thread handle does not terminate the associated thread. To remove a thread object, you must terminate the thread, and then close all handles to the thread.
When an application running in user mode calls this function, the kernel calls internal functions that clean up any associated resources, such as MyFileSystem_PreCloseHandle and MyFileSystem_CloseHandle.
|Windows Embedded CE||Windows CE 1.0 and later|
|Windows Mobile||Windows Mobile Version 5.0 and later|