CloseHandle Function

Action

Closes an open object handle previously opened with CreateEvent, CreateEventEx, CreateMutex or CreateMutexEx.

Include file

Kernel.bdh

Syntax

CloseHandle(in hHandle: number): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hHandle Object handle to close

Example

dcltrans
transaction TCloseHandle
var
hMutex: number;
begin
hMutex := CreateMutex("MutexObject");
write("mutex object created"); writeln;
WaitForSingleObject(hMutex, INFINITE);
ReleaseMutex(hMutex);
write("mutex object released"); writeln;
CloseHandle(hMutex);
write("handle to mutex object closed"); writeln;
end TCloseHandle;

Output

mutex object created
mutex object released
handle to mutex object closed