ReadFile function fails.

This is a discussion on ReadFile function fails. within the C++ Programming forums, part of the General Programming Boards category; I am having a problem with the ReadFile function. Here is the code: int size1 = GetFileSize( hfbm, NULL ); ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    2

    ReadFile function fails.

    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.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,588
    Please use [code][/code]Tags

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    If you look up 998 on the system error codes page, you'll probably be able to solve this problem on your own. If you are still having troubles please post back with the code for allocating bminfo.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  5. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21