网站首页  词典首页

请输入您要查询的函数:

 

术语 peeknamedpipe
释义 PeekNamedPipe
语法:
C++
BOOL WINAPI PeekNamedPipe(
__in HANDLE hNamedPipe,
__out_opt LPVOID lpBuffer,
__in DWORD nBufferSize,
__out_opt LPDWORD lpBytesRead,
__out_opt LPDWORD lpTotalBytesAvail,
__out_opt LPDWORD lpBytesLeftThisMessage
);
PeekNamedPipe功能
复制数据从一个命名或匿名管道到缓冲区没有从管道中删除它。此外它还提供了有关数据资料的管道。
参数
hNamedPipe [in]
阿管道句柄。此参数可以是一个处理到一个命名管道实例,如返回的CreateNamedPipe或CreateFile函数,也可以是一个句柄一个匿名管道读结束时,由CreatePipe函数返回。句柄必须GENERIC_READ访问管道。
lpBuffer [指出,可选]
一个接收数据从管道中读取缓冲区的指针。此参数可以为NULL,如果没有数据被读取。
nBufferSize [in]
至于由lpBuffer参数指定的缓冲区大小,以字节为单位。此参数被忽略,如果lpBuffer为NULL。
lpBytesRead [指出,可选]
一个变量,它接收从管道读取的字节数的指针。此参数可以为NULL,如果没有数据被读取。
lpTotalBytesAvail [指出,可选]
一个变量,它接收的字节总数可从管道读指针。此参数可以为NULL,如果没有数据被读取。
lpBytesLeftThisMessage [指出,可选]
一个变量,它接收此消息在剩余的字节数的指针。此参数将零字节型命名管道或匿名管道。此参数可以为NULL,如果没有数据被读取。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
该PeekNamedPipe功能类似于ReadFile函数但下列情况除外:
数据读取与CreateNamedPipe指定的模式。例如,创建一个PIPE_TYPE_MESSAGE管| PIPE_READMODE_MESSAGE。如果您更改模式PIPE_READMODE_BYTE与SetNamedPipeHandleState,ReadFile将读取字节模式,但PeekNamedPipe将继续读取消息模式。
数据读取管道不从管道的缓冲区删除。
该函数可以返回有关的管道内容的其他信息。
该函数总是返回立即在单线程应用程序,即使没有管道的数据。一个命名管道等方式处理(阻塞或非阻塞)没有对功能的影响。
注意PeekNamedPipe功能可以阻止线程的执行同样的方式向任何/ O函数时,可同步处理多线程应用程序调用我。为了避免这种情况,使用管道句柄创建异步I /输出。
如果指定的句柄是一个命名管道处理字节读模式,功能读取所有可用字节在nBufferSize到指定的大小。对于命名管道句柄的消息读模式,功能读取管道下一封邮件。如果邮件大于nBufferSize是,该函数返回TRUE,在阅读指定的字节数。在这种情况下,lpBytesLeftThisMessage将收到的邮件中剩余的字节数。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CreateFile
CreateNamedPipe
CreatePipe
管功能
管概述
ReadFile
WriteFile
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==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.
Syntax
C++
BOOL WINAPI PeekNamedPipe(
__in HANDLE hNamedPipe,
__out_opt LPVOID lpBuffer,
__in DWORD nBufferSize,
__out_opt LPDWORD lpBytesRead,
__out_opt LPDWORD lpTotalBytesAvail,
__out_opt LPDWORD lpBytesLeftThisMessage
);
Parameters
hNamedPipe [in]
A handle to the pipe. This parameter can be a handle to a named pipe instance, as returned by the CreateNamedPipe or CreateFile function, or it can be a handle to the read end of an anonymous pipe, as returned by the CreatePipe function. The handle must have GENERIC_READ access to the pipe.
lpBuffer [out, optional]
A pointer to a buffer that receives data read from the pipe. This parameter can be NULL if no data is to be read.
nBufferSize [in]
The size of the buffer specified by the lpBuffer parameter, in bytes. This parameter is ignored if lpBuffer is NULL.
lpBytesRead [out, optional]
A pointer to a variable that receives the number of bytes read from the pipe. This parameter can be NULL if no data is to be read.
lpTotalBytesAvail [out, optional]
A pointer to a variable that receives the total number of bytes available to be read from the pipe. This parameter can be NULL if no data is to be read.
lpBytesLeftThisMessage [out, optional]
A pointer to a variable that receives the number of bytes remaining in this message. This parameter will be zero for byte-type named pipes or for anonymous pipes. This parameter can be NULL if no data is to be read.
Return Value
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 PeekNamedPipe function is similar to the ReadFile function with the following exceptions:
The data is read in the mode specified with CreateNamedPipe. For example, create a pipe with PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE. If you change the mode to PIPE_READMODE_BYTE with SetNamedPipeHandleState , ReadFile will read in byte mode, but PeekNamedPipe will continue to read in message mode.
The data read from the pipe is not removed from the pipe's buffer.
The function can return additional information about the contents of the pipe.
The function always returns immediately in a single-threaded application, even if there is no data in the pipe. The wait mode of a named pipe handle (blocking or nonblocking) has no effect on the function.
Note The PeekNamedPipe function can block thread execution the same way any I/O function can when called on a synchronous handle in a multi-threaded application. To avoid this condition, use a pipe handle created for asynchronous I/O .
If the specified handle is a named pipe handle in byte-read mode, the function reads all available bytes up to the size specified in nBufferSize. For a named pipe handle in message-read mode, the function reads the next message in the pipe. If the message is larger than nBufferSize, the function returns TRUE after reading the specified number of bytes. In this situation, lpBytesLeftThisMessage will receive the number of bytes remaining in the message.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CreateFile
CreateNamedPipe
CreatePipe
Pipe Functions
Pipes Overview
ReadFile
WriteFile
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365779(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:23:09