CloseHandle
CloseHandle is a Windows API function that closes an open object handle. It is declared in Windows.h and implemented in kernel32.dll. The function accepts a single parameter, hObject, which is a HANDLE to an open kernel object such as a file, event, mutex, semaphore, timer, process, or thread. CloseHandle decrements the object's reference count and releases the system resources associated with the handle. When the final reference to the object is closed, the object is destroyed and its resources are freed. The function does not terminate the object itself; closing a process or thread handle merely releases the handle, not the process or thread.
Return value: CloseHandle returns a nonzero value on success and zero on failure. If it fails, the
Usage notes: You must close every handle you obtain from a Windows API function (or duplicate). Do