CreateNamedPipeW function
CreateNamedPipeW enables an enhanced version of the named pipes. Enhanced named pipes provide more control over pipe behavior and security.
For Windows Server 2008 R2 and Windows 7: The default behavior of named pipes changes when the application is compiled with the correct SDK. For more information, see "About Named Pipes".
HANDLE CreateNamedPipeW(
LPCWSTR lpName,
DWORD dwOpenMode,
DWORD dwPipeMode,
DWORD nMaxInstances,
DWORD nOutBufferSize,
DWORD pInBufferSize,
DWORD nDefaultTimeout,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
Syntax
| Parameter | Description |
|---|---|
lpName |
The name of the named pipe. This member can be an arbitrary string of characters. Use the format:
If the string does not begin with the specified prefix, the function fails. If |
dwOpenMode |
The trasmit mode and access mode of the pipe. This parameter can be a combination of the following values:
|
dwPipeMode |
The pipe's transmission mode and read/write modes. This parameter can be a combination of the following values:
|
nMaxInstances |
The maximum number of instances that can be created for this pipe. The first instance can be named This parameter must be a positive number. The value |
nOutBufferSize |
The recommended buffer size in bytes for the output buffer of the pipe. If this parameter is zero, the system uses the default buffer size. |
nInBufferSize |
The recommended buffer size in bytes for the input buffer of the pipe. If this parameter is zero, the system uses the default buffer size. |
nDefaultTimeout |
The default timeout in milliseconds for calls to the |
lpSecurityAttributes |
A pointer to a |
Return Value
If the function succeeds, the return value is an open handle to an instance of the named pipe. If the function fails, the return value is . To get error information, call INVALID_HANDLE_VALUE.GetLastError
| Return Value | Description |
|---|---|
INVALID_HANDLE_VALUE |
An error occurred. Call GetLastError for more information. |
Remarks
The CreateNamedPipeW function creates a named pipe server. A named pipe is a communication channel that is created on a network. Named pipes can be used for one-way or two-way communication between processes.
When a named pipe is created, it is assigned a name that is visible to the operating system. Client applications can use this name to connect to the pipe.
Named pipes can be created in either byte mode or message mode. In byte mode, data is transmitted as a stream of bytes. In message mode, data is transmitted as discrete messages.
Named pipes can be created in blocking mode or nonblocking mode. In blocking mode, calls to and ReadFile will block until the operation is complete. In nonblocking mode, these calls will return immediately, even if the operation is not yet complete.WriteFile
The flag enables overlapped I/O for the pipe, allowing multiple read and write operations to be in progress simultaneously.FILE_FLAG_OVERLAPPED
Requirements
| Interface | Value |
|---|---|
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | namedpipeapi.h (include windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |
| Unicode and ANSI Versions | CreateNamedPipeW (Unicode) and CreateNamedPipeA (ANSI) |