CloseHandle

This function closes an open object handle. A remote application interface (RAPI) version of this function exists, named CeCloseHandle.

At a Glance

Header file: Winbase.h
Windows CE versions: 1.0 and later

Syntax

BOOL CloseHandle( HANDLE hObject );

Parameters

hObject

Handle to an open object.

Return Values

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

The CloseHandle function closes handles to the following objects:

Communications device Mutex
Database Process
Event Socket
File Thread

CloseHandle 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.

Closing a thread handle does not terminate the associated thread. To remove a thread object, you must terminate the thread, then close all handles to the thread.

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

See Also

CreateFile, DeleteFile, FindClose, FindFirstFile