Link to home
Start Free TrialLog in
Avatar of Djafken
Djafken

asked on

reading disk sector in WinNT

I was wondering how I can read a sector of a hard disk. I was hoping I could do it with CreateFile('\\.\PhysicalDrive0',...) and then read the drive with ReadFile. But that doesn't work. CreateFile creates a handle ok, but ReadFile keeps me giving error 87 (wrong parameter). Anyone any ideas?

Kind regards,

Djafken
ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NickRepin
NickRepin

Hard, floppy, CD-ROM - no difference.
When performing direct disk I/O, you must seek, read, and write in multiples of sector sizes of the device and on sector boundaries. It seems that you don't, that's why you get this error.
Avatar of Djafken

ASKER

Thanks, the problem was indeed the sector size, just like you mentioned.