Index   Commented   Search   About

Overview
Group
Quick Info

Windows NT
Yes
Win95
Yes
Win32s
Yes
Import Library
kernel32.lib
Header File
winbase.h
Unicode
No
Platform Notes
None

CloseHandle

The CloseHandle function closes an open object handle.

BOOL CloseHandle(

HANDLE hObject
// handle to object to close
);

Parameters

hObject

Identifies an open object handle.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The CloseHandle function closes handles to the following objects:

  • Console input or output

  • Event file

  • File mapping

  • Mutex

  • Named pipe

  • Process

  • Semaphore

  • Thread

  • Token (Windows NT only)

CloseHandle invalidates the specified object handle, decrements the object's handle count, and performs object retention checks. Once the last handle to an object is closed, the object is removed from the operating system.

This function does not close module objects.

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

Closing an invalid handle raises an exception. This includes closing a handle twice, not checking the return value and closing an invalid handle, and using CloseHandle on a handle returned by FindFirstFile.

See Also

CreateFile
, DeleteFile, FindClose, FindFirstFile

Related Links

Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
TMS Scripter Studio Pro components for Delphi/C++Builder

More Online Helps

Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008 Free Tect Secrets ;) greatis just4fun network just4fun