Platform SDK: Interprocess Communications

GetNamedPipeHandleState

The GetNamedPipeHandleState function retrieves information about a specified named pipe. The information returned can vary during the lifetime of an instance of the named pipe.

BOOL GetNamedPipeHandleState(
  HANDLE hNamedPipe,             // handle to named pipe
  LPDWORD lpState,               // pipe state
  LPDWORD lpCurInstances,        // number of pipe instances
  LPDWORD lpMaxCollectionCount,  // maximum collection count 
  LPDWORD lpCollectDataTimeout,  // time before transmission
  LPTSTR lpUserName,             // client user name
  DWORD nMaxUserNameSize         // size of user name buffer
);

Parameters

hNamedPipe
[in] Handle to the named pipe for which information is wanted. The handle must have GENERIC_READ access to the named pipe.

Windows NT/2000: This parameter can also be a handle to an anonymous pipe, as returned by the CreatePipe function.

lpState
[out] Pointer to a variable that indicates the current state of the handle. This parameter can be NULL if this information is not needed. Either or both of the following values can be specified.
Value Meaning
PIPE_NOWAIT The pipe handle is in nonblocking mode. If this flag is not specified, the pipe handle is in blocking mode.
PIPE_READMODE_MESSAGE The pipe handle is in message-read mode. If this flag is not specified, the pipe handle is in byte-read mode.

lpCurInstances
[out] Pointer to a variable that receives the number of current pipe instances. This parameter can be NULL if this information is not required.
lpMaxCollectionCount
[out] Pointer to a variable that receives the maximum number of bytes to be collected on the client's computer before transmission to the server. This parameter must be NULL if the specified pipe handle is to the server end of a named pipe or if client and server processes are on the same computer. This parameter can be NULL if this information is not required.
lpCollectDataTimeout
[out] Pointer to a variable that receives the maximum time, in milliseconds, that can pass before a remote named pipe transfers information over the network. This parameter must be NULL if the specified pipe handle is to the server end of a named pipe or if client and server processes are on the same computer. This parameter can be NULL if this information is not required.
lpUserName
[out] Pointer to a buffer that receives the null-terminated string containing the user name string associated with the client application. The server can only retrieve this information if the client opened the pipe with SECURITY_IMPERSONATION access.

This parameter must be NULL if the specified pipe handle is to the client end of a named pipe. This parameter can be NULL if this information is not required.

nMaxUserNameSize
[in] Specifies the size, in TCHARs, of the buffer specified by the lpUserName parameter. This parameter is ignored if lpUserName is NULL.

Return Values

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.

Remarks

The GetNamedPipeHandleState function returns successfully even if all of the pointers passed to it are NULL.

To set the pipe handle state, use the SetNamedPipeHandleState function.

Requirements

  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

Pipes Overview, Pipe Functions, SetNamedPipeHandleState