Function Reference


Increases the count of the specified semaphore object by a specified amount

#include <WinAPIProc.au3>
_WinAPI_ReleaseSemaphore ( $hSemaphore [, $iIncrease = 1] )


$hSemaphore Handle to the semaphore object. The _WinAPI_CreateSemaphore() or _WinAPI_OpenSemaphore() function
returns this handle.
$iIncrease [optional] The amount by which the semaphore object's current count is to be increased. The value must be greater
than zero. If the specified amount would cause the semaphore's count to exceed the maximum count that
was specified when the semaphore was created, the count is not changed and the function returns 0. Default is 1.

Return Value

Success: The previous count for the semaphore.
Failure: Sets the @error flag to non-zero, call _WinAPI_GetLastError() to et extendd error information.


The state of a semaphore object is signaled when its count is greater than zero and nonsignaled when its count
is equal to zero. The process that calls the _WinAPI_CreateSemaphore() function specifies the semaphore's initial
count. Each time a waiting process is released because of the semaphore's signaled state, the count of the
semaphore is decreased by one.


_WinAPI_CreateSemaphore, _WinAPI_OpenSemaphore

See Also

Search ReleaseSemaphore in MSDN Library.


#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>

If Not @Compiled Then
    MsgBox($MB_SYSTEMMODAL, '', 'To run this script, you must first compile it and then run the (.exe) file.')

Local $hSemaphore = _WinAPI_CreateSemaphore('MySemaphore', 2, 2)


Func _MyGUI()
    GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
EndFunc   ;==>_MyGUI