Export (0) Print
Expand All

CallNamedPipe function

Connects to a message-type pipe (and waits if an instance of the pipe is not available), writes to and reads from the pipe, and then closes the pipe.

Syntax


BOOL WINAPI CallNamedPipe(
  _In_   LPCTSTR lpNamedPipeName,
  _In_   LPVOID lpInBuffer,
  _In_   DWORD nInBufferSize,
  _Out_  LPVOID lpOutBuffer,
  _In_   DWORD nOutBufferSize,
  _Out_  LPDWORD lpBytesRead,
  _In_   DWORD nTimeOut
);

Parameters

lpNamedPipeName [in]

The pipe name.

lpInBuffer [in]

The data to be written to the pipe.

nInBufferSize [in]

The size of the write buffer, in bytes.

lpOutBuffer [out]

A pointer to the buffer that receives the data read from the pipe.

nOutBufferSize [in]

The size of the read buffer, in bytes.

lpBytesRead [out]

A pointer to a variable that receives the number of bytes read from the pipe.

nTimeOut [in]

The number of milliseconds to wait for the named pipe to be available. In addition to numeric values, the following special values can be specified.

ValueMeaning
NMPWAIT_NOWAIT
0x00000001

Does not wait for the named pipe. If the named pipe is not available, the function returns an error.

NMPWAIT_WAIT_FOREVER
0xffffffff

Waits indefinitely.

NMPWAIT_USE_DEFAULT_WAIT
0x00000000

Uses the default time-out specified in a call to the CreateNamedPipe function.

 

Return value

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.

If the message written to the pipe by the server process is longer than nOutBufferSize, CallNamedPipe returns FALSE, and GetLastError returns ERROR_MORE_DATA. The remainder of the message is discarded, because CallNamedPipe closes the handle to the pipe before returning.

Remarks

Calling CallNamedPipe is equivalent to calling the CreateFile (or WaitNamedPipe, if CreateFile cannot open the pipe immediately), TransactNamedPipe, and CloseHandle functions. CreateFile is called with an access flag of GENERIC_READ | GENERIC_WRITE, and an inherit handle flag of FALSE.

CallNamedPipe fails if the pipe is a byte-type pipe.

Examples

For an example, see Transactions on Named Pipes.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

CallNamedPipeW (Unicode) and CallNamedPipeA (ANSI)

See also

CloseHandle
CreateFile
CreateNamedPipe
Pipe Functions
Pipes Overview
TransactNamedPipe
WaitNamedPipe

 

 

Community Additions

ADD
Show:
© 2014 Microsoft