DosCloseMutexSem

Syntax
DosCloseMutexSem( phmtxSemaphore )

Parameters

 * PHMTX phmtxSemaphore (input):This is a pointer to the HMTX that contains the handle to the semaphore to be closed.

Returns
0 NO_ERROR            Semaphore closed successfully 6 ERROR_INVALID_HANDLE Error, The value in phmtxSemaphore does not point to a valid semaphore 301 ERROR_SEM_BUSY      Error, Another thread in this process is blocked on the semaphore
 * APIRET rc:The following values can be returned:

Usage Explanation
DosCloseMutexSem decrements, by one (1), the usage count for the semaphore pointed to by phmtxSemaphore. If the usage count goes to zero (0) then the semaphore is freed from the system.
 * The usage count for private semaphores is always one (1) so all private semaphores will be freed on successful completion of this call.
 * Shared (named or unnamed) semaphores may have usage counts greater than one (1), therefore they may or may not be freed from system resources on successful completion of DosCloseMutexSem.

Sample Code

 * 1) define INCL_DOSSEMAPHORES
 * 2) include 

PHMTX phmtxMySemaphore; /* pointer to my semaphore handle */

/* a mutex semaphore is successfully created */ /* its handle is placed in phmtxMySemaphore */

rc = DosCloseMutexSem(phmtxMySemaphore);

if (rc != 0) {	 /* We got an error to take care of. */	}	else {	 /* The semaphore was successfully closed */ } 