Home

ReleaseSemaphoreHANDLE

ReleaseSemaphoreHANDLE is not an official Windows API name. The correct API is ReleaseSemaphore, which operates on a semaphore object identified by a HANDLE. Semaphores are kernel objects used to control access to a limited resource by maintaining a count.

The function signature is BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount). hSemaphore is a handle to

Behavior and usage: ReleaseSemaphore increments the semaphore’s current count by lReleaseCount. If the new count would

Return value and errors: The function returns a nonzero value on success and zero on failure. Use

Notes: ReleaseSemaphore does not itself acquire ownership or require prior ownership of the semaphore—its primary role

See also: CreateSemaphore, OpenSemaphore, WaitForSingleObject, WaitForMultipleObjects, synchronization objects.

a
semaphore
created
by
CreateSemaphore
or
opened
with
OpenSemaphore.
lReleaseCount
specifies
how
many
units
to
release
(signal)
the
semaphore.
lpPreviousCount,
if
non-NULL,
receives
the
semaphore’s
previous
count
before
the
release.
exceed
the
semaphore’s
maximum
count
(established
when
the
semaphore
was
created),
the
call
fails
and
the
semaphore’s
count
is
not
changed.
The
operation
may
unblock
threads
waiting
in
wait
calls
such
as
WaitForSingleObject
or
WaitForMultipleObjects,
allowing
them
to
proceed
according
to
the
new
count.
GetLastError
to
obtain
extended
error
information
when
it
fails.
Possible
failure
reasons
include
an
invalid
handle,
a
parameter
that
would
exceed
the
maximum
count,
or
insufficient
permissions
to
operate
on
the
semaphore.
is
to
signal
resource
availability.
The
lpPreviousCount
parameter
is
optional
but
can
be
useful
for
debugging
or
for
coordinating
complex
synchronization.