The SetNamedPipeHandleState function sets the read mode and the blocking mode of the specified named pipe. If the specified handle is to the client end of a named pipe and if the named pipe server process is on a remote computer, the function can also be used to control local buffering.
BOOL SetNamedPipeHandleState(
HANDLE hNamedPipe, // handle to named pipe
LPDWORD lpMode, // pointer to new pipe mode
LPDWORD lpMaxCollectionCount, // pointer to maximum collection count
LPDWORD lpCollectDataTimeout // pointer to time-out value
);
Windows NT: This parameter can also be a handle to an anonymous pipe, as returned by the CreatePipe function.
Mode | Description |
---|---|
PIPE_READMODE_BYTE | Data is read from the pipe as a stream of bytes. This mode is the default if no read-mode flag is specified. |
PIPE_READMODE_MESSAGE | Data is read from the pipe as a stream of messages. The function fails if this flag is specified for a byte-type pipe. |
One of the following wait modes can be specified:
Mode | Description |
---|---|
PIPE_WAIT | Blocking mode is enabled. This mode is the default if no wait-mode flag is specified. When a blocking mode pipe handle is specified in the ReadFile, WriteFile, or ConnectNamedPipe function, operations are not finished until there is data to read, all data is written, or a client is connected. Use of this mode can mean waiting indefinitely in some situations for a client process to perform an action. |
PIPE_NOWAIT | Nonblocking mode is enabled. In this mode, ReadFile, WriteFile, and ConnectNamedPipe always return immediately. Note that nonblocking mode is supported for compatibility with Microsoft® LAN Manager version 2.0 and should not be used to achieve asynchronous input and output (I/O) with named pipes. |
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Pipes Overview, Pipe Functions, ConnectNamedPipe, CreateFile, CreateNamedPipe, GetNamedPipeHandleState, ReadFile, WriteFile