WaitNamedPipe

  BOOL WaitNamedPipe(lpszPipeName, dwTimeout)    
  LPTSTR lpszPipeName; /* name of pipe to wait for */
  DWORD dwTimeout; /* timeout time in milliseconds */

The WaitNamedPipe function waits until an instance of the specified named pipe is in a listening state (that is, the pipe's server process has a pending ConnectNamedPipe operation on the pipe). If no instances of the specified pipe exist, the function will return immediately regardless of the timeout value. If the pipe exists, but no instances of the pipe are currently in a listening state, the function will wait for the specified timeout period.

If the function returns successfully, the process should use CreateFile to open a handle to the pipe.

Parameters

lpszPipeName

Points to a null-terminated string that specifies the name of the named pipe. The string must include the name of the machine on which the server process is executing. The following pipe name format is used:

\\servername\pipe\pipename

A period may be used for the servername if the pipe is local.

dwTimeout

Specifies the number of milliseconds the function will wait for the named pipe. If dwTimeout is NMPWAIT_USE_DEFAULT_WAIT, the function will use the default timeout time set by the CreateNamedPipe function. If dwTimeout is NMPWAIT_WAIT_FOREVER, the function will not return until the named pipe is available.

Return Value

The return value is TRUE if an instance of the pipe is available before the timeout period elapses. Otherwise, it is FALSE. Use the GetLastError function to obtain extended error information.

Comments

The WaitNamedPipe function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

CallNamedPipe, CreateNamedPipe, CreateFile