求助:GetLastError() == ERROR_IO_PENDING 问题?
xmzh 2006-03-24 09:42:19 boolean serialWrite(HANDLE h, int bytesToWrite,char* buffer,int *bytesWritten)
{
OVERLAPPED os = {0};
int res;
memset(&os,0,sizeof(OVERLAPPED));
os.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
res = WriteFile(h,buffer,bytesToWrite,bytesWritten,&os);
if( fWriteStat == 0 )
{
if( GetLastError() == ERROR_IO_PENDING )
{
while ( GetOverlappedResult(h,&os,numberOfBytesWritten,TRUE) == 0 )
{
dwError=GetLastError();
if( dwError == ERROR_IO_INCOMPLETE )
{
continue;
}
else
{
return FALSE;
}
}
}
}
return TRUE;
}
运行半天就会始终返回false,谁知道怎么回事?