I am having a problem with the ReadFile function. Here is the code:
int size1 = GetFileSize( hfbm, NULL );
for( int i = 0; i < size1; ++i ) {
int dummy;
if( ReadFile( hfbm, &bmInfo[i], 1,
&dwRead, (LPOVERLAPPED)NULL) == 0 ) {
DWORD error = GetLastError();
switch( error ) {
case ERROR_HANDLE_EOF:
FileWriter::Msg( "Error Handle EOF" );
break;
case ERROR_INVALID_USER_BUFFER:
FileWriter::Msg( "Error Invalid User Buffer" );
break;
case ERROR_NOT_ENOUGH_MEMORY:
FileWriter::Msg( "Error Not Enough Memory" );
break;
case ERROR_BROKEN_PIPE:
FileWriter::Msg( "Error Broken Pipe" );
break;
case ERROR_INSUFFICIENT_BUFFER:
FileWriter::Msg( "Error Insufficient Buffer" );
break;
case ERROR_MORE_DATA:
FileWriter::Msg( "Error More Data" );
break;
}
++dummy;
}
}
The ReadFile function fails on the 4616th byte. size1 is 196664. I don't know what the problem is. GetLastError returns 998, but that doesn't match up with any of the cases. Can someone please help me with this.