Partager via


CloseHandle (Windows CE 5.0)

Send Feedback

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

BOOLCloseHandle( HANDLEhObject);

Parameters

  • hObject
    [in] 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
  • Database
  • Database enumeration context
  • Event
  • File
  • File-mapping object
  • Mutex
  • Process
  • Socket
  • 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. Persistent objects such as databases and files will 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.

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

When an application running in user mode calls CloseHandle, the kernel calls internal functions that clean up any associated resources, such as MyFileSystem_PreCloseHandle and MyFileSystem_CloseHandle. If a user-mode call closes a handle, a failure of the internal preclose and close functions also causes CloseHandle to fail.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.

See Also

CreateFile | CreateFileForMapping | CreateFileMapping | CeFindFirstDatabaseEx | DeleteFile | FindClose | FindFirstFile

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.