Reading from a file
Posted on 1998-05-08
I am doing some DirectX programming with Visual C++ 5.0. I am currently trying to load in a bitmap file, and have a reference book with an example. The code they use for opening a file and reading from it is as follows:
HFILE hfile = _lopen(filename, OF_READ);
if( _lread( hfile, &m_bmFileHeader, sizeof(m_bmFileHeader)) == sizeof(m_bmFileHeader))
other code is here
The m_bmFileHeader is a structure of type BITMAPFILEHEADER which contains the following members:
Now, I know that _lopen and _lread are older 16-bit commands, and would like to replace them with a newer 32 bit command. I have looked at the fstream commands and also the CreateFile and ReadFile commands in VC++, but found that they do not work the same (and CreateFile seems like extreme overkill). What commands can I use as the equivalent. I really need to read in a block of bytes into this structure like they do in the _lread command above. Please help!
Thanks a lot... let me know if this question is harder than it seems...