BOOL PeekNamedPipe(hPipe, lpvBuffer, cbBuffer, lpcbRead, lpcbAvail, lpcbMessage) | |||||
HANDLE hPipe; | /* handle for pipe to peek from | */ | |||
LPVOID lpvBuffer; | /* address of data buffer | */ | |||
DWORD cbBuffer; | /* size in bytes of data buffer | */ | |||
LPDWORD lpcbRead; | /* number of bytes read | */ | |||
LPDWORD lpcbAvail; | /* total number of bytes available | */ | |||
LPDWORD lpcbMessage; | /* unread bytes in this message | */ |
The PeekNamedPipe function copies data from a named or anonymous pipe into a buffer without removing it from the pipe. It also returns information about data in the pipe.
hPipe
Specifies a handle to the named pipe. The handle must have GENERIC_READ access to the named pipe.
lpvBuffer
Points to a buffer for data read from the pipe. This parameter can be NULL if no data is to be read.
cbBuffer
Specifies the size in bytes of the buffer at lpvBuffer. This parameter is ignored if lpvBuffer is NULL.
lpcbRead
Points to a variable to be set to the number of bytes read from the pipe. This parameter can be NULL if no data is to be read.
lpcbAvail
Points to a variable to be set to the total number of bytes available to be read from the pipe. This parameter can be NULL if this information is not required.
lpcbMessage
Points to a variable to be set to the number of bytes remaining in this message. This will be zero for byte-mode pipes. This parameter can be NULL if this information is not required.
The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.
The results of the PeekNamedPipe function are similar to calling ReadFile on the pipe, except more information is returned, the function never blocks and a partial message can be returned if the pipe handle is reading in message mode.
A partial message peeked on a message mode pipe will return TRUE.
This function works with named pipes (pipes created by the CreateNamedPipe function) or anonymous pipes (pipes created by the CreatePipe function).
CreateNamedPipe, CreatePipe, ReadFile, WriteFile