【发布时间】:2010-09-11 04:41:01
【问题描述】:
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 );
如您所见,我使用PeekNamedPipe 来获取可用空间,但事实证明totalBytesAvailable 始终是0,如何正确操作?
【问题讨论】:
-
@Frerich - 当然,我在 SO 度过的时间。它知道它对 Alan 没有任何价值,但我当然在乎。考虑到它的价格,懒惰标记答案是愚蠢的。
-
我猜你正在写信给
hPipe,而不是一些未知的tmp_pipe?