views:

22

answers:

1

BTW the remaining buffer will automatically increase if the other side reads data out of it,right?

A: 

How about PeekNamedPipe? It would seem that the following will return the total number of bytes remaining to be read from the pipe.

DWORD totalBytesAvailable;
BOOL WINAPI PeekNamedPipe(
  handle,                // __in       HANDLE hNamedPipe,
  NULL,                  // __out_opt  LPVOID lpBuffer,
  0,                     // __in       DWORD nBufferSize,
  NULL,                  // __out_opt  LPDWORD lpBytesRead,
  &totalBytesAvailable,  // __out_opt  LPDWORD lpTotalBytesAvail,
  NULL                   // __out_opt  LPDWORD lpBytesLeftThisMessage
);
torak
`totalBytesAvailable` includes bytes written by both sides of pipe,right?
Alan
@Alan: I'm not sure. It says its the total available to read, which might mean just what this side of the pipe can read. However, I think that this is one of those cases where the easiest way to find out definatively will be to write some test code.
torak
It doesn't work,I just tried,`totalBytesAvailable` is always `0`
Alan