DosQueryMutexSem

DosQueryMutexSem returns the process ID, thread ID and request count of the owner of the mutex semaphore referred to by hmtxSemaphore.

Syntax
DosQueryMutexSem( hmtxSemaphore, ppidSemaphoreOwner, ptidSemaphoreOwner, pulRequestCount )

Parameters

 * HMTX hmtxSemaphore (input):The handle (HMTX) of the semaphore to be queried.
 * PPID ppidSemaphoreOwner (output):A pointer to the process ID structure (PID) that will get the ID of the semaphore owner.
 * PTID ptidSemaphoreOwner (output):A pointer to the thread ID structure (TID) that will get the ID of the current semaphore owner.
 * PUL pulRequestCount (output):A pointer to the ULONG that is to get the request count of the queried mutex semaphore. The request count is calculated by subtracting the number of releases from the number of requests made on the mutex semaphore. If the semaphore currently has no owner then the request count is zero (0).

Returns

 * APIRET rc:The following values can be returned

Usage Explanation
The process calling DosQueryMutexSem must first obtain access to the semaphore in question or ERROR_INVALID_HANDLE will be returned.

Sample Code

 * 1) define INCL_DOSSEMAPHORES
 * 2) include 

HMTX hmtxMySemaphore;     /* pointer to my semaphore handle */ PID  pidSemaphoreOwner;   /* will get PID of sem owner */ TID  tidSempahoreOwner;   /* will get TID of sem owner */ ULONG ulRequestCount;     /* will get the request count for the sem */

/* access is gained to the semaphore in question */ /* either by DosCreateMutexSem ... */	/* ... or by DosOpenMutexSem */ /* its handle is placed in hmtxMySemaphore */

rc = DosQueryMutexSem(hmtxMySemaphore,	                     &pidSemaphoreOwner,	                      &tidSemaphoreOwner,	                      &ulRequestCount);

if (rc != 0) {	 /* We got an error to take care of. */	}