2.1.4.1.3 CreateNamedPipe


Description

Creates an instance of a named pipe and returns a handle for subsequent pipe operations.

Syntax

HANDLE CreateNamedPipe( LPCTSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, PSECURITY_ATTRIBUTES lpSecurityAttributes )

Parameters

lpName
[input]The unique pipe name. This string must have the following form:
\\.\pipe\pipename
dwOpenMode
[input]The open mode. The function fails if dwOpenMode specifies anything other than 0 or the flags listed in the following tables.
PIPE_ACCESS_INBOUND, PIPE_ACCESS_OUTBOUND, PIPE_ACCESS_DUPLEX
dwPipeMode
[input]The pipe mode. The function fails if dwPipeMode specifies anything other than 0 or the flags listed in the following tables.
One of the following type modes can be specified. The same type mode must be specified for each instance of the pipe.
PIPE_TYPE_BYTE Data is written to the pipe as a stream of bytes. This mode cannot be used with PIPE_READMODE_MESSAGE.
PIPE_TYPE_MESSAGE Data is written to the pipe as a stream of messages. This mode can be used with either PIPE_READMODE_MESSAGE or PIPE_READMODE_BYTE.
One of the following read modes can be specified. Different instances of the same pipe can specify different read modes.
PIPE_READMODE_BYTE Data is read from the pipe as a stream of bytes. This mode can be used with either PIPE_TYPE_MESSAGE or PIPE_TYPE_BYTE.
PIPE_READMODE_MESSAGE Data is read from the pipe as a stream of messages. This mode can be only used if PIPE_TYPE_MESSAGE is also specified.
One of the following wait modes can be specified. Different instances of the same pipe can specify different wait modes.
PIPE_WAIT Blocking mode is enabled
PIPE_NOWAIT Nonblocking mode is enabled. In this mode, ReadFile, WriteFile, and ConnectNamedPipe always return immediately.
nMaxInstances
[input] The maximum number of instances that can be created for this pipe.
nOutBufferSize
[input] The number of bytes to reserve for the output buffer
nInBufferSize
[input] The number of bytes to reserve for the input buffer.
nDefaultTimeOut
[input] The default time-out value, in milliseconds
lpSecurityAttributes
[input] A pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new named pipe and determines whether child processes can inherit the returned handle.

Return

If the function succeeds, the return value is a handle to the server end of a named pipe instance.

If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.

Examples

Remark

To create an instance of a named pipe by using CreateNamedPipe, the user must have FILE_CREATE_PIPE_INSTANCE access to the named pipe object. If a new named pipe is being created, the access control list (ACL) from the security attributes parameter defines the discretionary access control for the named pipe.

All instances of a named pipe must specify the same pipe type (byte-type or message-type), pipe access (duplex, inbound, or outbound), instance count, and time-out value. If different values are used, this function fails and GetLastError returns ERROR_ACCESS_DENIED.

See Also

CallNamedPipe,ConnectNamedPipe

Header to Include

origin.h

Reference