hPipe = CreateNamedPipe(
lpszPipename, // pipe name
PIPE_ACCESS_DUPLEX, // read/write access
PIPE_TYPE_MESSAGE | // message type pipe
PIPE_READMODE_MESSAGE | // message-read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // max. instances
100, // output buffer size
100, // input buffer size
0, // client time-out
NULL); // default security attribute
DWORD totalBytesAvailable;
PeekNamedPipe(
hPipe , // __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
);
if(totalBytesAvailable allows)
WriteFile( tmp_pipe, pBuffer, BufferLen, &dwWritten, NULL );
As you see I used PeekNamedPipe
to get available space,but it turns out that totalBytesAvailable
is always 0
,how to do it properly?