DosSetNPipeSem can be used with local pipes or on the client end of a remote pipe. (A remote pipe is the client end of a pipe created on a remote named pipe server.) If an attempt is made to attach a semaphore to the server end of a remote pipe, DosSetNPipeSem returns 1 (ERROR_INVALID_FUNCTION).
If a semaphore is already attached to the specified handle, DosSetNPipeSem replaces the existing semaphore with the new one.