Advertisement

ReadFile();

Started by July 13, 2001 01:13 PM
2 comments, last by warm0ng3r 23 years, 7 months ago
Ok, im creating a bitmap reader, and its all fine, except for the 4th(?) parm of the ReadFile function, which is a pointer to the space already read in the file or somesuch.. could someone please explain this parameter and its usual values to me plz? here it is BOOL ReadFile( HANDLE hFile, // handle of file to read LPVOID lpBuffer, // pointer to buffer that receives data DWORD nNumberOfBytesToRead, // number of bytes to read LPDWORD lpNumberOfBytesRead, // pointer to number of bytes read LPOVERLAPPED lpOverlapped // pointer to structure for data ); i assumed it would be the start address of the part of the file from which you want to read, but i added the sizeof''s of the previous parts of the file to the start address of the file pointer, and its not the data it wants. Thats probably a vague description of the problem, but the best i can come up with at 2am, and im about to collapse onto the keyboar-fgdhjdf.htrlhjyi kithjoooo here in castle camelot we eat ham and jam and spam alot!
It looks to me that you do not need to set the 4th parameter explicitly. It is a pointer to a LPDWORD which the function uses to pass back how much of the data it managed to read, presumably so you can perform some error checking (if nNumberOfBytesToRead != lpNumberOfBytesRead).

BloatWare

Advertisement
You do not set the 4th parameter...

Instead create a DWORD or LPDWORD and just hand the address of the varaiable as the 4th parameter.

When the ReadFile() function returns, the only purpose of the BytesRead is that it will tell you exactly how many bytes it read... a good thing to use when error checking.

Use SetFilePointer() to adjust where you want to start reading from, and then the third param to adjust how many bytes you would like to read.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

My PGP Signature, Locate Public key on domain server.

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.1 for non-commercial use

iQA/AwUBOcbGNN42vCuvqlVSEQI2mQCglnHz5n1VcNacPQKRtSw8SAFGGWMAn1ei
GyvSAwu1npdATbq3BwdhXIA1
=Vm6v
-----END PGP SIGNATURE-----
Gamedev's AI Auto-Reply bot.
thankszors... yeah i think it is a variable used for checking.

The book im learning from (Lamothe''s Tricks of Windows bla bla bla) uses an awful lot of older functions and nothing in the way of OOP.... And I like OOP

Just wandering, is it better to put most of the rendering functions into a "renderer" class or somesuch? How do most other people implement graphics with OOP considerations? I hate loose functions eh.

here in castle camelot we eat ham and jam and spam alot!

This topic is closed to new replies.

Advertisement