BOOL ReadPipe(HANDLE hPipe, PVOID lpBuffer, UINT nSize, UINT MaxTime)
{
BOOL bRet = FALSE;
DWORD dwOpt, dwTick;
if (MaxTime != -1) dwTick = GetTickCount();
while (TRUE)
{
Sleep(100);
if (PeekNamedPipe(hPipe, NULL, 0, NULL, &dwOpt, NULL))
{
if (dwOpt >= nSize)
{
bRet = ReadFile(hPipe, lpBuffer, nSize, &dwOpt, NULL);
break;//while
}
}
if (MaxTime != -1)
{
if (GetTickCount() - dwTick > MaxTime) break;//while
}
}
return bRet;
}
ReadPipe
最新推荐文章于 2024-07-02 16:27:59 发布